A Beginner method to check whether a file exists

Submitted on: 1/23/2015 4:43:00 AM
By: Jacky Wong (from psc cd)  
Level: Beginner
User Rating: By 7 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 1083
     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.

				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
MsgBox "File doesn't exist!", vbCritical
Exit Function
End If
MsgBox "File doesn't exist!", vbCritical
Exit Function
End If
End Function

Other 1 submission(s) by this author


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)

To post feedback, first please login.