[RESOLVED] [2008] Delete Read Only files
My app is all but finished, just running through some final tests and I have discovered that I'm having trouble getting my program to delete read-only files ... unless I do it manually through Explorer I cannot seem to rid them, and I get an exception on debug.
So my question is how can I force it to delete a read only file.
I'm currently using
Code:
System.IO.Directory.Delete(tempdir, True)
to delete the dir and all its files. All goes well except for the read-only ones...
Re: [2008] Delete Read Only files
Hi,
You could, before deleting the file change it to normal and then delete it.
Here's an example how to change it to normal:
vb Code:
System.IO.File.SetAttributes(path, System.IO.FileAttributes.Normal)
Wkr,
sparrow1
Re: [2008] Delete Read Only files
Cheers for the hint sparrow :)
I wrote a little script that will change all files in a directory to normal recursively
Code:
For Each item In System.IO.Directory.GetFiles(tempdir)
System.IO.File.SetAttributes(item, IO.FileAttributes.Normal)
Next