Is there a way to tell if a certain file exists? Like a function or something? Perhaps:
FileExist("c:\Windows\whatever.txt")
Any help is appreciated.
Printable View
Is there a way to tell if a certain file exists? Like a function or something? Perhaps:
FileExist("c:\Windows\whatever.txt")
Any help is appreciated.
refer
http://vblib.virtualave.net
there is a function IsFileExist in vbFileIO class,
hope this help.
If you know the path of the file, you can use the Dir$ function to check whether the file exists.
And the code looks a bit like this:
function IsFileExist(szFileName as string) as boolean
' default to not exist
IsFileExist = false
if (dir(szFileName, vbNormal) <> "") then
' found it
IsFileExist = true
end if
end function
-Cool Bizs
Yes, and a one line solution as follows:
function IsFileExist(szFileName as string) as boolean
IsFileExist = (dir(szFileName, vbNormal) <> "")
End Function
Thanks a lot. It really helped.