|
-
Jul 4th, 2008, 01:56 PM
#1
Thread Starter
Hyperactive Member
[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...
-
Jul 4th, 2008, 02:35 PM
#2
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
-
Jul 4th, 2008, 11:52 PM
#3
Thread Starter
Hyperactive Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|