|
-
Feb 27th, 2001, 11:52 AM
#1
Thread Starter
Hyperactive Member
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)
-
Feb 27th, 2001, 11:57 AM
#2
_______
<?>
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
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Feb 27th, 2001, 12:04 PM
#3
Thread Starter
Hyperactive Member
File
Thanks,
Yeah that worked, how about when you wnat to confirm a file exists?
Dir("C:\Folder\MyFile.txt) ??
Regards,
-
Feb 27th, 2001, 12:07 PM
#4
_______
<?>
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"
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Feb 27th, 2001, 12:33 PM
#5
Thread Starter
Hyperactive Member
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,
-
Feb 27th, 2001, 12:47 PM
#6
_______
<?>
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"
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Feb 27th, 2001, 12:55 PM
#7
Thread Starter
Hyperactive Member
Works fine for the root but not when I branch off it?
Can't understand it?
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
|