Deleting "Read Only" files

  • Thread starter Thread starter James
  • Start date Start date
J

James

Hello,


Whenever I try to delete a Read Only file using FileInfoObject.Delete I get
"Access to the path "File name and path" is Denied" error. This does not
happen with other files. Any ideas? Thank you.
 
Using SetAttributes did the trick. Thanks!




Greg Young said:
Change it to not be readonly first.

You can get whether or not it is readonly by checking the FileInfo
object's attributes

http://msdn2.microsoft.com/en-us/library/system.io.file.getattributes.aspx

You can then set it to not be readonly using

http://msdn2.microsoft.com/en-us/library/system.io.file.setattributes.aspx


A quick google also brought up
http://www.thescripts.com/forum/thread270312.html which also suggests
using WMI which supposedly does not have the same restriction.

Cheers,

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top