Let say I have a file that contains a serialized object by BinaryFomatter. Now I want to be able to serialize another object and APPEND this on that existing file.
How can I do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First, if what you really need is to store an array of object – put them in a container and serialize the container, as said earlier.
Now, if you really want to store two serialized object in a single file concatenated:
I’m not sure that this is possible “out of the box”, but you can do two things.
Use, or invent your own semi-tar file format, in which you’ll write a small header in the beginning (or end) of the file that describes the content of the file (#’objects, and sizes).
Write a C# code to detect the beginning and end of each serialized object yourself. I’m not entirely sure it’s possible. Here is a non-official documentation of the serialization format. It contains header, however there’s no guarantee that this header won’t appear in the file.