Hi,
How can I know if a file already exists in a directory?
Printable View
Hi,
How can I know if a file already exists in a directory?
use Dir on it
VB Code:
If Len(Dir$("c:\winnt\win.ini"))>0 then msgbox "Exists!" else msgbox "Doesn't" end if
VB Code:
Function FileExist(ByVal strPath As String) As Boolean FileExist = Len(Dir(strPath)) <> 0 End Function
If you dont want to put in the full path every time and only check within 1 directory, before you call the function do this:VB Code:
ChDir "C:\MyDir"
Thanks a lot.