Search Tools Links Login

A Beginner method to check whether a file exists

Posted: 2002-06-01
By: ArchiveBot
Viewed: 80

Filed Under:

VB6 Code Cache

No attachments for this post


A Beginner method to check whether the file exists or not. Simple and should able to run on different Window OS.

Original Author: Jacky Wong

Code

Public Function CheckFile(InFileName As String) As Boolean

  On Error GoTo ErrHandler

  CheckFile = False

  If Dir(InFileName) <> "" Then

    If (GetAttr(InFileName) And vbDirectory) = 0 Then

      CheckFile = True

    Else

      MsgBox "File doesn't exist!", vbCritical

      Exit Sub

    End If

  Else

    MsgBox "File doesn't exist!", vbCritical

    Exit Sub

  End If

ErrHandler:

  
End Function


Comments on this post

No comments have been added for this post.

You must be logged in to make a comment.