vb: how to check file existence?
Website Design
Website Promotion
Graphic Design
Programming
Free Software
Computer Tips
Discount Stores
|
This site provides users with the information about vb, visual basic, vb6, check file existence, how to check file existence, and more.
If you think that this site is helpful, please recommend your friends to visit our site.
How to check file exsitence?
The following are the steps to check file existence:
1. Create a Sub with the following code:
Private Sub Command1_Click()
If FileExists(App.Path + "\test.dat") Then
Open App.Path + "\test.dat" For Random As #1 Len = 100
Else
MsgBox "The file '" + App.Path + "\test.dat' does not exist.", _
vbCritical + vbOKOnly, "File not found"
End If
End Sub
2. Add the following Function in BAS module
Public Function FileExists(FileName As String)
On Error Resume Next
FileExists = (Len(Dir(FileName)) > 0)
End Function
|