I'm trying to write larger chunks to increase the speed of the file save. I have about 9 of these loops to convert but I can't figure out what I'm doing wrong
fs := TFileStream.Create(Myfile, fmCreate);
This code works:
for RecordGroup := 0 to TotalGroups - 1 do
begin
for RecordNumber := 0 to Length(MyArray[RecordGroup]) - 1 do
begin
fs.WriteBuffer(MyArray[RecordGroup,RecordNumber],SizeOf(MyRecord));
end;
end;
When I remove the innerloop to write bigger chunks, the code does not work:
for RecordGroup := 0 to TotalGroups - 1 do
begin
fs.WriteBuffer(MyArray[RecordGroup],SizeOf(MyRecord) * Length(MyArray[RecordGroup]));
end;
I get the generic error 'Stream write error'
The value of SizeOf(MyRecord) * Length(MyArray[RecordGroup])
is 180 * 152,004 = 27,360,720
Everything I've read basically says this is correct. Any ideas what I'm doing wrong?
Thanks in advance for any ideas you may have.