Live Chat Icon For mobile
Live Chat Icon

WPF FAQ - Serialization

Find answers for the most frequently asked questions
Expand All Collapse All

Stream mystream = new IsolatedStorageFileStream( storeFileName, FileMode.Create, isoStorage );
if( null != mystream )
XmlTextWriter xmlwriter = new XmlTextWriter(mystream, Encoding.UTF8);
      this.WriteDateToWriter( xmlwriter );


Serialization is the process of converting the state of the object to a stream, so that it can be saved and transported. The reverse process of serialization is called Deserialization, where a stream is converted back to an object. The objective of serialization process is persistence of objects in an application. There are two types of Serialization: ’Binary and ’SOAP’ serialization respectively.


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

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

Please submit your question and answer.