Advertisement
6_2008-2009 Files/ File Controls/ Input/ Output #200286

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.

AI

ИИ-обзор: 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.

Исходный код
original-source
Public Function CheckFile(InFileName As String) As Boolean <br>
 On Error GoTo ErrHandler <br>
 CheckFile = False <br>
 'Check whether the file or folder exist <br>
 If Dir(InFileName) <> "" Then <br>
 'Check is it a directory(folder) <br>
 If (GetAttr(InFileName) And vbDirectory) = 0 Then <br>
  CheckFile = True <br>
 Else <br>
  MsgBox "File doesn't exist!", vbCritical <br>
  Exit Function <br>
 End If <br>
 Else <br>
 MsgBox "File doesn't exist!", vbCritical <br>
 Exit Function <br>
 End If <br>
ErrHandler: <br>
 
End Function
Оригинальные комментарии (3)
Восстановлено из Wayback Machine