-
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?
-
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
-
Awesome - thanks a lot! :)
-