I am trying to figure some code out to delete Cookies, BrowserHistory and Cache.
I am not sure excactly what this code will delete ?
What I want to delete is:
* Temporary Internet files
* Cookies
* History
* Form data
* Passwords
* InPrivate Filtering data
However when pressing the button that runs the code, I get an error:
"Access to the path '2CEDBFBC-DBA8-43AA-B1FD-CC8E6316E3E2.dat' is denied."
How is this possible to adjust so I get permission to delete ?
private void button2_Click(object sender, EventArgs e)
{
//Delete
clearIECache();
}
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);
}
}