Deleting "Read Only" files

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

Greg Young

J

James

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

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,228
Latest member
MikeMichal

Latest Threads

Top