0

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

Edited by Lukezzz: n/a

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by sknake
0

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

Edited by sknake: n/a

0

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...

0

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.

Edited by sknake: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.