The internet cache files are stored in 'Temporary Internet Files' folder. So basically what you need to do is to delete all the files that are present in that folder. In order to do this;
private void EmptyCacheFolder(DirectoryInfo folder)
{
foreach (FileInfo file in folder.GetFiles())
{
file.Delete();
}
foreach (DirectoryInfo subfolder in folder.GetDirectories())
{
EmptyCacheFolder(subfolder);
}
}
public bool ClearCache()
{
bool isEmpty;
try
{
EmptyCacheFolder(new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)));
isEmpty = true;
}
catch
{
isEmpty = false;
}
return isEmpty;
}