by Anonymous (267 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Mon 28th December 1998
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Determine if a directory exists
' FUNCTION: DirExists
'
' Determines whether the specified directory name exists.
' This function is used (for example) to determine whether
' an installation floppy is in the drive by passing in
' something like 'A:\'.
'
' IN: [strDirName] - name of directory to check for
'
' Returns: True if the directory exists, False otherwise
'
Public Function DirExists(ByVal strDirName As String) As Integer
Dim strDummy As String
On Error Resume Next
If Right$(strDirName, 1) <> "\" Then
strDirName = strDirName & "\"
End If
strDummy = Dir$(strDirName & "*.*", vbDirectory)
DirExists = Not (strDummy = vbNullString)
Err = 0
End Function