Parsi Coders

نسخه‌ی کامل: خالی کردن کش اینترنت اکسپلورر(emety cach folder)
شما در حال مشاهده نسخه آرشیو هستید. برای مشاهده نسخه کامل کلیک کنید.
کد:
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;

        }