Sunday, May 09, 2004

How to clear the Downloaded Cache programatically?

The most important thing that you must considerate before clear the Downloade Cache programmatically it's that the .NET Framework has a default 50MB quota for this cache, so that you don't have to worry about the growing without a size controlled. Additionally, this API won't work for further versions of the .NET Framework. Please check the Alan Shi's blog for more information.
The following C# code clears the Downloaded Cache:

using System.Runtime.InteropServices;
sealed class App
{
[DllImport("fusion.dll")]
static extern void NukeDownloadedCache();
static void Main()
{
NukeDownloadedCache();
}
}