WPF FAQ - Serialization

Find answers for the most frequently asked questions
Expand All Collapse All
[C#]

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

Permalink

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.

Permalink

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();

Permalink

Share with

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

Please submit your question and answer.