Link to home
Start Free TrialLog in
Avatar of cuntacinte
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
Avatar of vinnyd79
vinnyd79

If Dir("C:\Filename.txt") <> "" Then
ASKER CERTIFIED SOLUTION
Avatar of vinnyd79
vinnyd79

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cuntacinte

ASKER

Thanks vinnyd79

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