
Detecting if a path exists...
Here's one way using the API. It returns True if the path exists, and false if not. It
doesn't matter if the path passes is in long or short filename format.
Declare Function GetShortPathName Lib "kernel32" _
Alias "GetShortPathNameA" _
(ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, _
ByVal cchBuffer As Long) As Long
Function PathExists(pathToCheck As String) As String
Dim dummy As String
Dim nSize As Long
dummy = Space$(255)
nSize = Len(dummy)
PathExists = GetShortPathName(pathToCheck, dummy, nSize) <> 0
End Function
Private Sub Command1_Click()
Print PathExists("c:\win")
End Sub
--
Randy Birch, MVP Visual Basic
VBnet, The Visual Basic Developers Resource Centre
http://home.sprynet.com/sprynet/rasanen/vbnet/default.htm
:Is there a way to test a path to see if it exists in VB? I have a dir()
:call that crashes if the drive or path does not exist and I would like
:to not use standard error handling to solve this problem. Thanks.
:
:Bejay Cole
: