monte Posted March 4, 2006 Posted March 4, 2006 Hello, I've got a file open error: Unable to open file. I am administrator of box so it's not a privilege issue. Any ideas? Thanks. $file = FileOpen("test.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileClose($file)
GaryFrost Posted March 4, 2006 Posted March 4, 2006 might try adding the path to the file in the open SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
monte Posted March 4, 2006 Author Posted March 4, 2006 I've tried that already, no good: $file = FileOpen("C:\docume~1\olvermo\Desktop\test.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileClose($file)
GaryFrost Posted March 4, 2006 Posted March 4, 2006 (edited) I would try something like: If FileExists(@DesktopDir & "\text.txt") Then $file = FileOpen(@DesktopDir & "\test.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileClose($file) Else MsgBox(0, "Error", "File not found") EndIf Edited March 4, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
monte Posted March 4, 2006 Author Posted March 4, 2006 ok, I can use your code and then write to the file: If FileExists(@DesktopDir & "\text.txt") Then $file = FileOpen(@DesktopDir & "\text.txt", 1) filewrite($file,"hello there") ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileClose($file) Else MsgBox(0, "Error", "File not found") EndIf however, I want to be able to create the file if it doesn't exist....I figured it out. Thanks for your help! If NOT FileExists(@DesktopDir & "\text.txt") Then $file = FileOpen(@DesktopDir & "\text.txt", 1) filewrite($file,"hello there") FileClose($file) endif
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now