Objects can be serialized to a binary file using the System.Runtime.Serialization and System.Runtime.Serialization.Formatters.Binary namespaces.
The following code snippet is used to write a stream to a binary file.
[C#]
SerializeTest st = new SerializeTest();
File file = new File('temp.dat');
Stream stream = file.Open(FileMode.Create);
BinaryFormatter binaryformatter = new BinaryFormatter();
binaryformatter.Serialize(stream, st);
stream.Close();
Share with