Does anyone else find that the Dir Function doesn't fully work?
Even tried the example in MSDN Library and that doesn't work?
It works fine for a file on the root, but nothing is returned once I branch off the root.
I'm using Win 2000, VB6 Pro (SP4)
Printable View
Does anyone else find that the Dir Function doesn't fully work?
Even tried the example in MSDN Library and that doesn't work?
It works fine for a file on the root, but nothing is returned once I branch off the root.
I'm using Win 2000, VB6 Pro (SP4)
Works for me...Code:'check to see if a folder or directory does
Private Sub Command1_Click()
If Dir("C:\MyFolder\MySub", vbDirectory) <> "" Then
MsgBox "Folder exists"
Else
MsgBox "Folder does not exist"
End If
End Sub
Thanks,
Yeah that worked, how about when you wnat to confirm a file exists?
Dir("C:\Folder\MyFile.txt) ??
Regards,
Code:...could be any of the the two and using Dir$ makes it
'faster as per the string conversion factor
1> If Dir$("C:\myFile.txt") then MsgBox "File Exists"
2> If len(Dir$("C:\myFile.txt")) > 0 then MsgBox "File Exists"
The second is fine on the root.
Do I need to change to the dirrect I want to search in first?
The first gives me a Type Mismatch.
Regards,
Yes..if it is in any subDir it is not in the root.
Ie.
C:\myText.text is in C and can be found using
If len(Dir$("C:\myFile.txt")) > 0 then MsgBox "File Exists"
C:\my Documents\myfile.txt is not in the root of C
and can only be found using the dir/subdir
If len(Dir$("C:\my Documents\myFile.txt")) > 0 then MsgBox "File Exists"
Works fine for the root but not when I branch off it?
Can't understand it?