Opened 10 years ago

Closed 10 years ago

#2904 closed Bug (No Bug)

FileOpen does NOT return an error when path is invalid.

Reported by: ILLBeBack Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: FileOpen Cc:


The FileOpen function does not return an @error value of –1 when the path is invalid. The following script demonstrates this by using multiple colons in the path.

#include <FileConstants.au3>

ConsoleWrite("Define an InValid path for a file name by use of multiple colons." & @LF)
Local $sFile = "d:::\xxxx\Test.txt"
ConsoleWrite("$sFile=" & $sFile & @LF)

Local $h1 = FileOpen($sFile, $FO_OVERWRITE + $FO_CREATEPATH)
If @error = -1 Then
    ConsoleWrite($sFile & " is an INvalid filename. " & @LF)
    $sFile = @ScriptDir & "\TVLister.xml"
    ConsoleWrite($sFile & " is a valid filename. " & @LF)

ConsoleWrite("FileExists(" & $sFile & ")=" & FileExists($sFile) & @LF)
If FileExists($sFile) Then FileDelete($sFile)


Tested in v3.3.12.0 and v3.3.13.19

Attachments (0)

Change History (2)

comment:1 Changed 10 years ago by MHz

@error will always be 0 after use of FileOpen as FileOpen does not set @error. It is the return value of $h1 that is tested with -1 as a check for failure.

Note, the word "error" is not the same as the macro "@error" as mentioned in the help file in the failure section.

comment:2 Changed 10 years ago by BrewManNH

  • Resolution set to No Bug
  • Status changed from new to closed

This isn't a bug, the function sets the return value to -1, it does not set @error.

You should be posting these "bug" reports to the forum before posting them here, it would have been explained to you without us having to go through the effort of closing the track tickets.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The ticket will remain with no owner.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.