Geekpedia Programming Tutorials






Delete All Temporary Internet Files Of IE

Delete all the temporary files from Internet Explorer's cache folder using basic methods available in the System.IO namespace.

On Friday, October 17th 2008 at 09:31 PM
By Andrew Pociu (View Profile)
***--   (Rated 2.8 with 6 votes)
Contextual Ads
More C# Resources
Advertisement
  1. using System.IO;
  2.  
  3. public static void Main()
  4. {
  5.    ClearFolder(new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache))); // Execute ClearFolder() on the IE's cache folder
  6. }
  7.  
  8. void ClearFolder(DirectoryInfo diPath)
  9. {
  10.    foreach (FileInfo fiCurrFile in diPath.GetFiles())
  11.    {
  12.       fiCurrFile.Delete();
  13.    }
  14.    foreach (DirectoryInfo diSubFolder in diPath.GetDirectories())
  15.    {
  16.       ClearFolder(diSubFolder); // Call recursively for all subfolders
  17.    }
  18. }
  19.  
Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this code snippet
Comment Current Comments
by somekind on Sunday, October 19th 2008 at 05:30 PM

Why it does not work?

by irtu on Thursday, November 20th 2008 at 10:49 AM

neat

by onetime on Monday, December 8th 2008 at 12:14 AM

good one

by a on Monday, December 8th 2008 at 12:14 AM

xyx

by kundan on Saturday, March 14th 2009 at 12:25 PM

what about index.dat. it is not deleting...

by kundan on Saturday, March 14th 2009 at 12:29 PM

what about index.dat. it is not deleting...

by aaa on Saturday, August 8th 2009 at 09:13 PM

did not work for me. only returned one file.

by jj on Tuesday, August 11th 2009 at 08:49 AM

ah, the trick is the directories too. when you look at the Temporary Internet Files in windows explorer, it shows everything as if it was all there. its actually scattered through out a number of folder.s

by Vishal Rastogi on Tuesday, September 22nd 2009 at 03:56 AM

Its unable to delete index.dat...


Comment Comment on this tutorial
Name: Email:
Message:
Comment Related Source Code
There is no related code.

Comment Related Tutorials
There are no related tutorials.

Jobs C# Job Search
My skills include:

Enter a City:

Select a State:


Advanced Search >>
Latest Tech Bargains

Advertisement

Free Magazine Subscriptions

Today's Pictures

Today's Video

Other Resources

Latest Download

Latest Icons