I think my qusetion is very easy but I don't know how
to do it...
How can I know if a file exist?
Printable View
I think my qusetion is very easy but I don't know how
to do it...
How can I know if a file exist?
Use the Dir function. You can get info on using it at msdn.microsoft.com/library/default.asp Look at the toc and goto Microsoft Visual Studio-->Visual Basic-->Reference-->Language Reference-->Functions-->D-->Dir
Code:If Dir$("MyFile") Then
'File exist
Else
'File does not exist
End If
I always use the Filelen(pathname) function. This determines the size of the file in bytes. For example:
If Filelen("C:\Windows\Win.exe) > 0 then
'file exists
Else
'file doesn't exist (figures)
End if
Hope this helps!
Dave.
Thanks to all of you :)
you're quick.
It almost faster than the MSDN. And I didn't want to search
into that.