-
hi,
i'm creating a file using this code
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("C:\nax.txt", True)
a.writeline ("Part one completed, reg code will finally go here")
a.Close
and i want a want a way on form load that i can check to see if that file excists or not
thanks
Merlin ?
-
Try opening it:
Set File= fs.GetFile("C:\nax.txt")
If len(file)=0 then
'File not found!!
end if
cheers,
André
-
finding files
thanks andre
but now im getting the message
"Object not found "
Any Ideas
Merlin ?
-
Is the error message "Object Required" ?
If yes, you probably did not Set the fs object in your form load, try this:
Private Sub Form_Load()
On Error Resume Next
Set fs = CreateObject("Scripting.FileSystemObject")
Set File = fs.GetFile("C:\nax.txt")
If Err.Number = 53 Then 'File not found
MsgBox "File Not Found"
End If
If Err.Number = 0 Then 'File found
MsgBox "File Found"
End If
End Sub
-
Thanks a lot
hi,
thanks andre it works brilliantly now
i have got the program fully working now
Cheers again
Merlin ?
-
FileExists
An alternative method is the use the .FileExists function. This returns true if the file exists and false if it doesn't.
Code:
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists("c:\nax.txt") then
'do whatever
Else
MsgBox "File Not Found"
End If
[Edited by Iain17 on 05-18-2000 at 04:05 PM]