by Marshall Youngblood (1 Submission)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating:
(2 Votes)
Determine if a directory exists. It is a variation of the vbcoders function I borrowed called 'FileExists that always works'.
Inputs
A path name to be checked (as string)
Assumes
Directory length are size 0. But just even though checking to see if the file is zero length works, it isn't good enough. Some files can be 0 length also. Using GetAttr function with the mask vbDirectory ensures that what you're looking at is indeed a directory.
Code Returns
true if path if valid
API DeclarationsAPI not used
Function PathExists(FullPath as string) as Boolean
'based on function borrowed from Planet Source Safe
Dim blnDirectory As Boolean
On Error Resume Next
If FileLen(FullPath) = 0& Then
If Err = 0 Then
blnDirectory = (GetAttr(FullPath) And vbDirectory)
If blnDirectory Then PathExists = True
End If
End If
End Function