-
This should be an easy question for you guys...
At the beginning of my program, I want to see if a folder exists, and if it does, I want to delete it. Dir() does not seem to be working. It is still drawing a "" when I know the folder exists. This is my code:
If Dir(App.Path & "\temp") <> "" Then RmDir (App.Path & "\temp")
How do I get this to work?
-
Try this:
Code:
If Dir(App.Path & "\temp", vbDirectory) Then
Or you could just try to remove the folder and catch the error if it doesn't exist:
Code:
On Error Resume Next
RmDir App.Path & "\Temp"
Good luck!
-
Worked great, Joacim. Thank you.
-
Joacim, you get an typemismatch with just a string
Code:
If len(Dir(App.Path & "\temp", vbDirectory)) Then
-
Kedaman's right. I used
Code:
If Dir(App.Path & "\temp", vbDirectory) <> "" Then
-
Yes of course! This is what's happening when you type the code directly into the post.
-
Hehe, which usually happens to me :( but obviously it happens to everyone :)