Checking for the existence of files ?

I

Isis

I am setting some variables with file names and want to check
for their existence before proceeding in my VB code - how do I
do that ? All files will be held on a local hard drive.

Thanks for any help

Regards
 
J

John Spencer

Are you setting the variables with the full path name?

If so, you can use DIR(yourVariable) and see if it returns a zero-length
string.

If Dir(YourVariable) = "" Then
' File does not exist
' Do something
else
' Files does exist.
' Do something else
End If

If you just have the file name without the path, then life is more
complicated.
 
I

Isis

Are you setting the variables with the full path name?

If so, you can use DIR(yourVariable) and see if it returns a zero-length
string.

If Dir(YourVariable) = "" Then
' File does not exist
' Do something
else
' Files does exist.
' Do something else
End If

If you just have the file name without the path, then life is more
complicated.


I am being good and using fully qualified paths so that will
work for me I think.

Thanks very much for the info.

Regards
 
Top