|
-
Apr 15th, 2001, 09:50 PM
#1
Thread Starter
New Member
In my program, I want it to detect if a file is there - if it is not, then the necessary files and folders for my program haven't been created yet and will need to be. If it is there (which it would be after my program has been installed), then the program won't need installing.
Code:
Open Filepath & "\general\InstallDetect.txt" For Input As #FileName
On Error GoTo InstallProgram
Close #FileName
Despite the On Error Statement, it still gives an error. How can I prevent this?
-
Apr 15th, 2001, 09:54 PM
#2
first of all, you have to setup your error trap before the point that would cause an error, so like this :
Code:
On Error GoTo InstallProgram
Open Filepath & "\general\InstallDetect.txt" For Input As #FileName
Close #FileName
but if you want to check if the file is there before you open it use this code :
Code:
If Len(Dir$(Filepath & "\general\InstallDetect.txt")) <>0 Then
Open Filepath & "\general\InstallDetect.txt" For Input As #FileName
'...
Close #FileName
End If
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Apr 15th, 2001, 10:01 PM
#3
Thread Starter
New Member
Awesome - thanks a lot!
-
Apr 15th, 2001, 10:02 PM
#4
no problem
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
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
|