Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File exist

Status
Not open for further replies.

cyberwolf14

Programmer
Aug 27, 2001
65
0
0
BE
How do I now a file exist??

for example I wan t check if the file "c:\test.dat" exist if I start my project
How do I do that??
 
If FileExists("c:\test.dat") Then
'file is here
else
'file does not exist
end if


Public Function FileExists(strPath As String) As Integer
On Error GoTo ERROR_FileExists
FileExists = Not (Dir(strPath) = "")
Exit Function

ERROR_FileExists:

End Function
 
Simpler:



If Dir("C:\test.dat") = "" then 'doesn't exist
do something
Else 'does exist
do something else
Endif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top