Jump to content

FileRead - Error allocating memory


Cyber
 Share

Recommended Posts

Hi!

I must do read a file

the code is simple:

$filename = "D:\ter\TE.txt"

$timer = TimerInit()

$SuperMegaGigaFile = FileRead($filename)

MsgBox(0,"",Round(TimerDiff($timer)/1000))

The problem?

The file size of the file is: 460m

text file

:)

Console Browse: Navigate on the WEB in a textual consoleMultiPing!: Show computer on the lan and/or show the local/remote task, ALL animated!KillaWin: Event executingCryptPage: Crypt your webpage and show only with key
Link to comment
Share on other sites

To read a file that large you'd need roughly 2GB of RAM to run effectively. How much do you have? There are also threads on reading files by parts through buffers. Try one of those.

Link to comment
Share on other sites

It's not just one function, it's a custom method. Just search the forum for "file buffer" or something similar. Also you need to realize the 2GB was a guess as to how much you would need, you may need more you may not need that much.

Link to comment
Share on other sites

  • 3 years later...

; "Error allocating memory."

; MAX_BINARYSIZE 2,147,483,647 Maximum bytes of binary data.

; MAX_STRINGLEN 2,147,483,647 Maximum string length.

$Path = "D:TmpFile.tmp"

$Size = 200*1024*1024 ; 200 Mb

If FileExists($Path) Then FileDelete($Path)

RunWait(@Comspec&' /C fsutil file createnew "' & $Path & '" ' & $size, '', @SW_HIDE)

If FileExists($Path) Then _Open($Path)

Func _Open($Path)

$file = FileOpen($Path, 0)

$text = FileRead($file)

FileClose($file)

MsgBox(0, Round(FileGetSize($Path)/1024/1024, 2)&' Mb', 'Yes')

EndFunc

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...