Jump to content
JDRenk

Adding a header to a bin file

Recommended Posts

How do I save binary data to a file with a fixed header?  Like using APPEND for text.

Share this post


Link to post

Are you in control of both the data and the header? If yes, open the file for writing in your preferred method (AssignFile, TFiles, TFileStream) and write the header, then the data.

 

If you get a file from an external source and you need to add a header, the easiest solution is a stream. Write your header and then copy the data from said file, loaded in a TFileStream.

 

 If you receive one header files and need to append data, all 3 methods (AssignFile, TFile, TFileStream) can append binary data to it.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×