Link to home
Create AccountLog in
Avatar of webressurs
webressursFlag for Norway

asked on

Problem when deleting a directory (Directory.Delete(path))

I have problems getting the Directory.Delete(path) working all the time when deleting empty folders. Sometimes the directory is deleted, but sometimes is seems like it is deleted (no error occurs) but the folder is still shown. When trying to open the folder in "my computer" I get the merror message "Access is denied". If I right click the folder it is write protected. If I manually try to put the folder in recycle bin I get the message "Cannot delete the file, Access denied". Even if I have removed the write protection. The folder seems deleted, but is still shown....?

I guess this has to do with access rights or something? Is it possible to set some access rights (in my code) to the folder before deleting it?

Thanks for all tips!!
Directory.Delete(path,false);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jeeva Subburaj
Jeeva Subburaj
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Have the same issue but only with PDF documents. Any ideas?