In a Delphi program, I have a dynamic array with 4,000,000,001 cardinals. I'm trying to write (and later read) it do a drive. I used the following:
const Billion = 1000000000;
stream := tFileStream.Create( 'f:\data\BigList.data', fmCreate);
stream.WriteBuffer( Pointer( BigArray)^, (4 * billion + 1) * SizeOf( cardinal));
stream.free;
It bombed out with: ...raised exception class EWriteError with message 'Stream write error'.
The size of the file it wrote is only 3,042,089KB.
Am I doing something wrong? Is there a limit to the size that can be written at once (about 3GB)?
The
Countparameter ofWriteBufferis a 32 bit integer so you cannot pass the required value in that parameter. You will need to write the file with multiple separate calls toWriteBuffer, where each call passes a count that does not exceed this limit.I suggest that you write it something like this.
An additional benefit is that you can readily display progress.