Checks whether a file exists at a location before trying to open it (traps file errors)
Checks whether a file exists at a location before trying to open it (traps file errors)
API Declarations
'# Created By Rob Hendricks - IBM Corporation#
'# Created on 25/07/01 #
Rate Checks whether a file exists at a location before trying to open it (traps file errors)
(2(2 Vote))
'declares the location variable
location = "C:\readme.txt"
'sets the location variable to the readme.txt file on c:If Dir$(location) <> "" Then
'checks whether the readme file exists, if dir$ returns anything other than "" then the file exists
Open location For Input As #1
'opens the file to be put into a text box inthe next line
Text1 = Input(LOF(1), #1)
'puts the whole contents ofthe file into the tex1 textbox
Close #1
'closes the file again
Else
MsgBox "File not found at this location, Please Check the Path", , "File Not found"
'displays an error message if the file doesnt exist
End If
Checks whether a file exists at a location before trying to open it (traps file errors) Comments
No comments yet — be the first to post one!
Post a Comment