locked
Clearing all caches RRS feed

  • Question

  • There seem to be all sorts of cache files as well as folders that contain useless temp files. They take up a lot of space. How do I purge them all with one or two simple commands.

    Also, which cache and tmp folders can be safely purged

    Wednesday, May 22, 2013 4:01 AM

All replies

  • Which domain you want to use for the code?(C#,Java,VB etc?)

    Also did you mean you want to clear them from browser cache or the system temp files?

    See if this helps

    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 ();
    }


    Mark as answer if this solves your problem. ... Best Regards D. Chatterjee MCA, RERF


    Wednesday, May 22, 2013 5:01 PM