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

What version of windows are you receiving this on? Anything created in your profile should be a candidate for deletion by the current user.

I am using Windows XP Proffessional Version 2002.

I am not sure why access is denied and what I can do about it ? I am logged in as administrator etc...

Honestly I would just catch IOException on your two calls for GetFiles() and GetDirectories() then call it a day. Audit what files are remaining, and if they're critical.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.