Hi, How can I know if a file already exists in a directory?
Rita Jaques
use Dir on it VB Code: If Len(Dir$("c:\winnt\win.ini"))>0 then msgbox "Exists!" else msgbox "Doesn't" end if
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"
Function FileExist(ByVal strPath As String) As Boolean FileExist = Len(Dir(strPath)) <> 0 End Function
ChDir "C:\MyDir"
You just proved that sig advertisements work.
Thanks a lot.
Forum Rules