Simple Data Serialization
The Windows .NET 2.0 framework provides different methods for serializing objects, but sometimes all that you need is simple binary data serialization. Here is one approach that is a bit more homespun than what the framework provides, but there is no doubt how it serializes data without requiring much code at all.
The key to this method is the BitConverter class. This class contains methods for converting standard data types to byte arrays and byte arrays back into standard data types. The BitConverter.GetBytes method takes a standard data type like a bool, int, double, long, etc. and converters the value into a byte array representation of how it is stored in memory. Methods such as ToBoolean, ToInt32, and ToDouble take the byte array representation and assign it to a standard data type.
Here is an example of an application (PixFlip Animator) that saves out and opens an animation project where the width and height of the movie along with all of the image frames are stored:
This example just stores out a few properties, data lengths, and the data streams to a file. This approach tends to work well when much of the data is binary to begin with.