I have the following structures in Delphi 2009:
type
IndiReportIndi = record
IndiName: string;
NameNum: integer;
ReportIndiName: string;
end;
var
XRefList: array of IndiReportIndi;
where XRefList is a dynamic array.
I want to save XRefList to a FileStream. How do I do that AND include all the IndiName and ReportIndiName strings so that they will all be retrievable again when I later load from that FileStream?
Simple TFileStreamEx to save variables
http://forum.chertenok.ru/viewtopic.php?t=4642
Work with them from 2005th year, without any problems...
Tested solution:
Just for the answer to be accurate:
Consider taking a look at the
TDynArray
wrapper, which is able to serialize any record into binary, and also to/from dynamic arrays.There are a lot of
TList
-like methods, including new methods (like hashing or binary search).Very optimized for speed and disk use, works for Delphi 5 up to XE2 - and Open Source.
See also How to store dynamic arrays in a TList?
Use: http://code.google.com/p/kblib/
To save whole XRefList to stream use:
To load it back:
To read those data you use a TReader and ReadInteger/ReadString.