Search

Clear Internet Explorer cache

This C# code snippet deletes all the Temporary Internet files, i.e. clears the Internet Explorer cache.
using System;
using System.IO; 

void clearIECache()
{
   ClearFolder (new DirectoryInfo (Environment.GetFolderPath
      (Environment.SpecialFolder.InternetCache)));
}
 
void ClearFolder (DirectoryInfo folder)
{
   foreach (FileInfo file in folder.GetFiles())
      { file.Delete(); }
   foreach (DirectoryInfo subfolder in folder.GetDirectories())
      { ClearFolder(subfolder); }
}
 
public static void Main( )
{
   new Test().clearIECache ();
}