Jump to content

[Solved] Read file with specific format


Recommended Posts

Hi everyone

I try to use something like that but it's goin 0x error!

$FilePath = FileOpen("settings.data")
$FileRead = FileRead($FilePath)
MsgBox(0,0,$FileRead)
$FileClose = FileClose($FilePath)

If i try to open .txt file it's fine and working perfectly but if i try to use with this format , i got error :'(

Thanks

Edited by zxtnt09
Link to comment
Share on other sites

Your code works perfectly fine on my computer. Have you tried any error handling?

$FilePath = FileOpen("settings.data")

If ($FilePath = -1) Then
    MsgBox("", "", "Failed to open settings.data")
    Exit
EndIf

$FileRead = FileRead($FilePath)

If (@Error) Then
    MsgBox("", "", "Error reading file, error code = " & @error & @CRLF & "Error message = " & (@error = -1 ? "End-of-file is reached, (Empty file)" : "File was not opened in read mode or other error"))
    Exit
EndIf

MsgBox(0,0,$FileRead)

$FileClose = FileClose($FilePath)

 

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

×
×
  • Create New...