blez
blez

Reputation: 5037

System can delete a file, but my program can't?

I have a file that can't be deleted by using File.Delete() - "Permission denied" or DeleteFile(). With the standard way it can be deleted without any problem. Using Unlocker, it showed that no handle is attached.

EDIT: The file was opened in another application. I don't know why Unlocker didn't detect it.

Upvotes: 0

Views: 544

Answers (2)

Mark Hall
Mark Hall

Reputation: 54532

Look at the Parent Directory and the File's property's security tab. Verify what permissions are granted to them. This should let you know what your problem is.

enter image description here

Upvotes: 1

Noel Frostpaw
Noel Frostpaw

Reputation: 3999

As it says, the application running has no access to that file. If your application created that file, check if you're calling the delete with the same credentials. If your application did not create this file, it's possible it's in a location that you don't have access to.

Upvotes: 0

Related Questions