i want to search for file. i know the directory and file name. All i know to search this file inside the directory before do anything.
Amal
Printable View
i want to search for file. i know the directory and file name. All i know to search this file inside the directory before do anything.
Amal
Public Function FileExists(strPath As String) As Integer
FileExists = Not (Dir(strPath) = "")
End Function
Or use filesystem object(add the Microsoft Scripting Runtime reference to the project)
dim objfso as FileSystemObject
Set objfso = CreateObject("Scripting.FileSystemObject")
if objfso.FileExists(objfso.BuildPath(strDirectory,strFileName)) then
msgbox "File exists"
else
msgbox "File does not exist"
end if
Unless you have multiple uses for FileSystemObject it shouldn't be an option as when you package your application you will have to add the extra baggage of the dll for the FSO. (scrrun.dll)