Memoryblock or temporary file

XOJO 2019r3.2 - Windows Desktop

I have a program that handles midi and style files. A style file is a midi file too, but there is more information after the midi-data (more chunks).
Only one file at a time will be loaded into the app.
A dll is used to read/save all the midi-data of the file, it does not handle the extra chunk-data.

To not lose the extra chunk-data I read this extra data into a Memoryblock and save it as a temporary file. When saving I add the extra data again at the end of the file.

My question : is it necessary to save the extra data to a temporary file or can I let it in the Memoryblock until it is needed to re-add it to the file when saving.
I.e is it wise to keep the data in the memoryblock until needed for saving ?
The temporary data is of no use after the end of the app.
The number of bytes of the extra data is not that big (between 0 and 30000 bytes perhaps)

I’m aware that if an error should end my app before a save i lose the memoryblock data, but that is not an issue for me.


You can base a BinaryStream on a MemoryBlock, which allows you to write data to it and the MemoryBlock resizes as needed. No file needed.

1 Like

Thanks for the reply Christian.