Advertisement
2002VB Files/ File Controls/ Input/ Output #20984

A Beginner method to check whether a file exists

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

AI

Resumen de IA: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Código fuente
original-source
Public Function CheckFile(InFileName As String) As Boolean <br>
  On Error GoTo ErrHandler <br>
  CheckFile = False <br>
  If Dir(InFileName) <> "" Then <br>
    If (GetAttr(InFileName) And vbDirectory) = 0 Then <br>
      CheckFile = True <br>
    Else <br>
      MsgBox "File doesn't exist!", vbCritical <br>
      Exit Sub <br>
    End If <br>
  Else <br>
    MsgBox "File doesn't exist!", vbCritical <br>
    Exit Sub <br>
  End If <br>
ErrHandler: <br>
  
End Function
Comentarios originales (3)
Recuperado de Wayback Machine