A Beginner method to check whether a file exists
A Beginner method to check whether the file exists or not. It is simple, easy to understand and should able to run on different Window OS.
Rate A Beginner method to check whether a file exists
(8(8 Vote))
Public Function CheckFile(InFileName As String) As Boolean
On Error GoTo ErrHandler
CheckFile = False
'Check whether the file or folder exist
If Dir(InFileName) <> "" Then
'Check is it a directory(folder)
If (GetAttr(InFileName) And vbDirectory) = 0 Then
CheckFile = True
Else
MsgBox "File doesn't exist!", vbCritical
Exit Function
End If
Else
MsgBox "File doesn't exist!", vbCritical
Exit Function
End If
ErrHandler:
End Function
A Beginner method to check whether a file exists Comments
No comments yet — be the first to post one!
Post a Comment