I have a folder named "Pictures" containing gif files.
Suppose I want to insert the file "New.gif" in that folder.
How do I check whether a file with the name "New.gif" already exists in the folder "Pictures".
I prefer
Public Function FileExist(a_file As String) As Boolean
On Error GoTo FileExist_Err
FileExist = False
FileExist = ((GetAttr(a_file) And vbDirectory) = 0)
On Error GoTo 0
Exit Function
FileExist_Err:
End Function
which return true if file (with full path) exist otherwise false. Error checking is needed in case that there's no file.
In case that a_file is a directory return false.
Bye
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.