|
-
Oct 8th, 2000, 10:18 PM
#1
Thread Starter
Addicted Member
How do you check to see if a file exists?
-
Oct 8th, 2000, 10:35 PM
#2
Use the Dir function.
Code:
If Dir("C:\file.exe") <> "" Then
'file exists
Else
'file does not exist
End If
-
Oct 8th, 2000, 10:40 PM
#3
Thread Starter
Addicted Member
-
Oct 9th, 2000, 01:38 AM
#4
Junior Member
or you can use this...
Function FileExists(strPath As String) As Boolean
Dim lngRetVal As Long
On Error Resume Next
lngRetVal = Len(Dir$(strPath))
If Err Or lngRetVal = 0 Then
FileExists = False
Else
FileExists = True
End If
End Function
This way you can do something like this.
If FileExists("C:\temp\seenit.txt") = True Then
MsgBox "They Seen it!"
else
MsgBox "Didn't see it!"
End If
-
Oct 9th, 2000, 02:17 PM
#5
Or use the FileSystemObject.
Code:
Dim X As FileSystemObject
If X.FileExists("MyFile.txt") Then 'File does exist
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|