Jump to content

Can Fileread read a file sized 500K in one go?


Guest Abalone
 Share

Recommended Posts

Guest Abalone

When I read a big file (eg 500K) using fileread without specifying the size. It will go into an endless loop

$filehandle=FileOpen("Source",4)

$filehandle2=fileopen("Target",2)

While 1

$buffer=FileRead($filehandle,65534) //It won't work if I use "$buffer=FileRead($filehandle)"

If @error = -1 Then ExitLoop

filewrite($filehandle2,HTMLtoCSV($buffer))

WEnd

FileClose($filehandle)

FileClose($filehandle2)

Did I do something wrong? Thank you!

Link to comment
Share on other sites

Did I do something wrong? Thank you!

yes. Your error check does not take care of all possible error values.

From help file: FileRead()

Return Value

Success: Returns the binary/string read.

Special: Sets @error to -1 if end-of-file is reached.

Failure: Sets @error to 1 if file not opened in read mode or other error.

Sets @error to 2 if count not defined for file open in raw read mode. <== THIS is your problem!

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

When I read a big file (eg 500K) using fileread without specifying the size. It will go into an endless loop

If you don't specify the size, it reads completaly the file and it doesn't make errors, then it will go into endless loop.
A lan chat (Multilanguage)LanMuleFile transferTank gameTank 2 an online game[center]L'esperienza è il nome che tutti danno ai propri errori.Experience is the name everyone gives to their mistakes.Oscar Wilde[/center]
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...