4
votes

My application (vb.net) sometimes throws an "access denied" exception when attempting to delete files in the AppData folder and I'm not sure why.

I confirm that the file exists before attempting to delete it and have not done anything to make it readonly, etc.

The interesting thing is that it seems to go okay when I'm logged in with Admin rights. However, I thought that the AppData folder did not require admin rights.

Any help would be greatly appreciated!

Thanks!

4
Give the permission to full access for Everyone to your AppData folderAnubrij Chandra

4 Answers

5
votes

My gut instincts without seeing your code is that maybe you have this file opened in your program or in another program?

4
votes

Maybe these files were created when you launched your application being logged on as Admin? So you get this error when you try to delete them later as normal user.

4
votes

It is not necessarily the folder, but the Owner of the file you are trying to interact with. If the File is owned by Administrators, you may have problems.

1
votes

AppData is a protected hidden folder because it is meant for your applications to store Local, LocalLow and Roaming application related data. This is why you would get prompted with a UAC prompt when you try to head into the folder and it is also hidden from view.

Try to use the Privilege demand attribute in your code to request process elevation to access the folder.