Here I’m going to demonstrate how to delete all Temporary Internet Files of

Internet Explorer through C#.Net.


private void btnDelete_Click(object sender, EventArgs e)
//creating directory info and asigning it the path of internet cache.
DirectoryInfo di = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache));
//assigning no. of directories in the folder to x
            int x = di.GetDirectories().Count();            
//calling clear() method
//clear() Method
        public void clear(DirectoryInfo di)
//loop for each file in directory           
            foreach (FileInfo fi in di.GetFiles())
//deleting the file
                catch (Exception ex)
//claaing clear() method recursively for each directory in current directory.
            foreach (DirectoryInfo sub in di.GetDirectories())
  Modified On Jul-28-2019 10:17:24 PM

Leave Comment