Live Chat Icon For mobile
Live Chat Icon

How do I serialize objects to a binary file ?

Platform: WPF| Category: Serialization

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.


SerializeTest st = new SerializeTest();
File file = new File('temp.dat');
Stream stream = file.Open(FileMode.Create);
BinaryFormatter binaryformatter = new BinaryFormatter();
binaryformatter.Serialize(stream, st);

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.