public static void DeserializeItem(string fileName, IFormatter formatter) { FileStream s = new FileStream(fileName, FileMode.Open); MyItemType t = (MyItemType)formatter.Deserialize(s); Console.WriteLine(t.MyProperty); }
public static void SerializeItem(string fileName, IFormatter formatter) { // Create an instance of the type and serialize it. MyItemType t = new MyItemType(); t.MyProperty = "Hello World"; FileStream s = new FileStream(fileName, FileMode.Create); formatter.Serialize(s, t); s.Close(); }