I am trying to clear the Tempoary Internet Files from my PC using C#. I have manually checked where they are sitting which is "C:\Documents and Settings\EPorter\Local Settings\Temporary Internet Files".
However, my code is returning "C:\Documents and Settings\EGP\ASPNET\Local Settings\Temporary Internet Files ", where EGP is the name of my PC.
Not sure what is going on but could do with some help please - thanks.
public void ClearIECache()
DirectoryInfo myDirectoryInfo = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache));
if (myDirectoryInfo.Exists == false)
string myCache_1 = myDirectoryInfo.FullName;
myChache_2 = System.IO.Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache));
//Get all files in Temporary internet
foreach (string myCache in myChache_2)
//files, folder and then set their attribute to normal then delete
//Delete the directory.