Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about HAndling Directory. 1

Status
Not open for further replies.

EdRev

Programmer
Aug 29, 2000
510
US
I have this function that finds out if a directory exist.

Function dirExists(path As String) As Boolean
On Error Resume Next
dirExists = Dir$(path) <> &quot;&quot;
'MsgBox (Dir$(path))
'MsgBox (path & dirExists)
End Function

and I have this sub to pass the pathname to this function:

boolDir = direxists(txtFileName.text), where txtFileName.text is assigned as &quot;c:\cases\year&quot;

although I know for sure that this is a valid path (I had to create it to test), the dirExists function returns false.

Is this function not reading the path that I'm passing it with?

Any help will be greatly appreciated.



 
Simple fix. Just change Dir$(path) to Dir$(path, vbDirectory). This tells VB that you're looking for a directory instead of a file. Take a look at Dir$ and Dir in Help. You might be in for a nice surprise :).
 
thanks LegoArtist. I wish all my programming problems will have the same simple fix as this.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top