cuntacinte
asked on
How to know if a file exists
Has anyone got code to find out if a file exists before I use it in my app.
C
C
If Dir("C:\Filename.txt") <> "" Then
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks vinnyd79
C
C
Function FileExist(Fname As String) As Boolean
On Local Error Resume Next
FileExist = (Dir(Fname) <> "")
End Function
' Use
If FileExist("C:\MyFile.txt" Then
Debug.Print "File Found"
End If
On Local Error Resume Next
FileExist = (Dir(Fname) <> "")
End Function
' Use
If FileExist("C:\MyFile.txt" Then
Debug.Print "File Found"
End If