I have defined a record which has lots of fields with different types (integer, real , string, … plus dynamic arrays in terms of “array of …”).
I want to save it as a whole to a file and then be able to load it back to my program. I don’t want to go through saving each field’s value individually.
The file type (binary or ascii or …) is not important as long Delphi could read it back to a record.
Do you have any suggestions?
You can load and save the memory of a record directly to and from a stream, as long as you don’t use dynamic arrays. So if you use strings, you need to make them fixed:
You can even load or save an array of record at once!
In case you want to write dynamic content:
After that, you can read it back: