|
-
Jul 3rd, 2000, 08:48 AM
#1
Thread Starter
Hyperactive Member
Ok this code below works for a file
If Dir$("\windows\car") <> "" Then
msgbox "The File Car Exist"
Else
msgbox "The File Doesn't Exist"
end if
-------
But i don't want to do it for a file i want to do it with a dir.
If Dir$("\windows\") <> "" Then
msgbox "The File Car Exist"
Else
msgbox "The File Doesn't Exist"
end if
If it exist, I get the right msg box...if it doesnt exist....i get a error that path doesnt exist.....y doesnt it skip to the else statement like the file does? And how can i fix it....thanks!
-RaY
VB .Net 2010 (Ultimate)
-
Jul 3rd, 2000, 08:54 AM
#2
Addicted Member
Try This!!
Try using the "Not" Operator, hmm might help.
-
Jul 3rd, 2000, 09:29 AM
#3
Addicted Member
Code:
If Dir$("\windows\",vbDirectory) <> "" Then
MsgBox "The File Car Exist"
Else
MsgBox "The File Doesn't Exist"
End If
...might work. The Dir function has a second optional parameter.
Visual Basic 6 Enterprise Edition + SP4
-
Jul 3rd, 2000, 09:39 AM
#4
Thread Starter
Hyperactive Member
Ok the real reply here hehe
Nope tried both idea's didnt work...the first idea...it just reversed the error...and with the 2nd idea, same error.....keep it coming guys im sure its something small, but i can't just find it!
-RaY
VB .Net 2010 (Ultimate)
-
Jul 3rd, 2000, 09:49 AM
#5
Addicted Member
Here's the exact code from my program which is tried and tested and DOES work in VB6.
Code:
If Dir(App.Path & "\Data\", vbDirectory) = "" Then MkDir App.Path & "\Data"
That code checks to see if a directory exists, and if it doesn't it creates it.
I just noticed you're using VB3 which might be the problem. Unfortunately VB6 is all I have, so I can't test it.
If the vbDirectory constant isn't defined in VB3, then just substitute it for it's value (16). If THAT doesn't work then, I dunno.
Visual Basic 6 Enterprise Edition + SP4
-
Jul 3rd, 2000, 09:52 AM
#6
Addicted Member
Just had a thought...
I wonder if, when you're referring to folders, you have to specify the FULL path - i.e. 'C:\WINDOWS\' instead of '\WINDOWS\'??
Visual Basic 6 Enterprise Edition + SP4
-
Jul 3rd, 2000, 09:54 AM
#7
Junior Member
You might want to try this:
dim temp as string
on error resume next
temp = Dir("\windows\",vbDirectory)
if err <> 0 then
msgbox "Does not exist..."
else
msgbox "Exists...."
end if
or using File System Object:
dim fso as variant
set fso = createobject("FileSystemObjects")
if fso.FolderExists("\windows\") then
msgbox "Exists..."
else
msgbox "Does not exist...."
end if
hope this helps....
-
Jul 5th, 2000, 07:35 AM
#8
Thread Starter
Hyperactive Member
Thanks Zeee!
thanks a lot guys but zee's worked great, u da man!
-RaY
VB .Net 2010 (Ultimate)
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
|