Parsi Coders
خالی کردن کش اینترنت اکسپلورر(emety cach folder) - نسخه قابل چاپ

+- Parsi Coders (http://parsicoders.com)
+-- انجمن: Software Development Programming (http://parsicoders.com/forumdisplay.php?fid=37)
+--- انجمن: C# Programming (http://parsicoders.com/forumdisplay.php?fid=55)
+--- موضوع: خالی کردن کش اینترنت اکسپلورر(emety cach folder) (/showthread.php?tid=1180)



خالی کردن کش اینترنت اکسپلورر(emety cach folder) - Ghoghnus - 10-31-2011

کد:
private void EmptyCacheFolder(DirectoryInfo folder)

        {

            //loop through all the files in the folder provided

            foreach (FileInfo file in folder.GetFiles())

            {

                file.Delete();

            }

            foreach (DirectoryInfo subfolder in folder.GetDirectories())

            {

                //recursively delete all files and folders in each sub directory

                EmptyCacheFolder(subfolder);

            }

        }

        public bool ClearCache()

        {

            //variable to hold our status

            bool isEmpty;

            try

            {

                //call EmptyCacheFolder passing the default internet cache

                //folder

                EmptyCacheFolder(new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)));

                isEmpty = true;

            }

            catch

            {

                isEmpty = false;

            }

            return isEmpty;

        }