Jump to content

FileClose generates error code: -1


Recommended Posts

  • Moderators

That doesn't sound like a return value for FileClose() but maybe the error for the wrong File Handle for FileOpen().

$Var1 = FileOpen()

FileClose($Var1) << contains the File Handle for FileOpen... That's the only thing I can think of that would throw a -1 error.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

FileClose() can't be used with filenames -- you must pass it a handle generated by FileOpen().

Here's an example use of FileOpen() and FileClose():

Local $Handle = FileOpen('C:\File.txt')
If $Handle <> -1 Then
   ; Perform file operations
    Local $Data = FileReadLine($Handle)
   ; ···
    FileClose($Handle)
EndIf
Link to comment
Share on other sites

  • Moderators

FileClose() can't be used with filenames -- you must pass it a handle generated by FileOpen().

Here's an example use of FileOpen() and FileClose():

Local $Handle = FileOpen('C:\File.txt')
If $Handle <> -1 Then
  ; Perform file operations
    Local $Data = FileReadLine($Handle)
  ; ···
    FileClose($Handle)
EndIf
Hmmm, that's what I had tried to say, but much more elequently put! :P

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...