Delete IE Temp files


We can delete the temporary files of IE. Following are the code part of delete the files.


using System.IO;

public static void Main()
{
ClearIETemp(new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)));
}

void ClearIETemp(DirectoryInfo MyDirPath)
{
foreach (FileInfo MyFile in MyDirPath.GetFiles())
{
MyFile.Delete();
}
foreach (DirectoryInfo MySubFolder in MyDirPath.GetDirectories())
{
ClearIETemp(MySubFolder);
}
}



1. By using "Environment.SpecialFolder.InternetCache" we can get the
temp folder of IE files
2. The method "ClearIETemp" is used to deleted each file of the tempory files
3. recursive call of this method deleted all the subdirectory files also.

Thanks
Nathan


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: