Click to See Complete Forum and Search --> : existing files
cloud311
April 14th, 2001, 04:03 PM
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.
cksiow
April 15th, 2001, 02:08 AM
refer
http://vblib.virtualave.net
there is a function IsFileExist in vbFileIO class,
hope this help.
shree
April 15th, 2001, 08:26 AM
If you know the path of the file, you can use the Dir$ function to check whether the file exists.
coolbiz
April 15th, 2001, 11:06 AM
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
shree
April 15th, 2001, 11:12 AM
Yes, and a one line solution as follows:
function IsFileExist(szFileName as string) as boolean
IsFileExist = (dir(szFileName, vbNormal) <> "")
End Function
cloud311
April 15th, 2001, 11:50 AM
Thanks a lot. It really helped.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.