|
-
Feb 27th, 2002, 04:34 PM
#1
Thread Starter
Fanatic Member
Deleting "Read Only" file?
Hey, I just found a small bug in my program. When a user tries to delete a file that they have selected in the listview, and the file is a "read only" file, Runtime error '75 occurs. File Path access denied. I'm using the "Kill" function to delete files. How can I make it delete a "read-only file" without causing an error? Any help is appreciated.
-
Feb 27th, 2002, 04:38 PM
#2
Hyperactive Member
Check the attributes of the file first. If it is read-only, then change the attribute to -r and then KILL it.
"If I had known it was going to be that kinda party, I would have stuck my disk in the mash potatos!"
-
Feb 27th, 2002, 04:44 PM
#3
Thread Starter
Fanatic Member
How would I do that?
How would I check the file attributes and change the read only propery? API?
-
Feb 27th, 2002, 04:59 PM
#4
Addicted Member
something like this;
Dim fso As New FileSystemObject
Set fil1 = fso.GetFile("c:\YourDirectory\" & aFile)
If fil1.Attributes = 1 Then
fil1.Attributes = 0
End If
then kill it
-
Feb 27th, 2002, 05:08 PM
#5
Thread Starter
Fanatic Member
multiple attributes?
A file has more than one attribute right? Like read only, archived,etc. How do I know which one to set?
-
Feb 27th, 2002, 05:34 PM
#6
Addicted Member
look at the file attributes in your object browser and there is a list of all the attributes. search filesystemobject and you will see the fileattribute, click on fileattribute and you will see all of the members.
-
Feb 27th, 2002, 05:37 PM
#7
Addicted Member
oh i didn't read your question right. Just set the attribute to 0 or Normal and kill it!
-
Jul 16th, 2002, 09:55 AM
#8
Courchjo,
I am not given the choice of FileSystemObject when dimming fso. You wouldn't happen to know what library I should be referancing? thx
-
Jul 16th, 2002, 10:28 AM
#9
Addicted Member
Hey, Use the reference to Microsoft Scripting Runtime
C:\winnt\system32\scrrun.dll
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
|