public static void Save(Window window, string file) { using (FileStream stream = new FileStream(file, FileMode.Create)) { BinaryFormatter formatter = new BinaryFormatter(); WindowSettings settings = new WindowSettings(); settings.AssignFrom(window); formatter.AssemblyFormat = FormatterAssemblyStyle.Simple; formatter.Serialize(stream, settings); stream.Close(); } }
public static void Save(Window window, Stream stream) { if (stream == null) throw new ArgumentNullException("stream"); WindowSettings settings = new WindowSettings(); settings.AssignFrom(window); XmlSerializer serializer = new XmlSerializer(typeof (WindowSettings)); serializer.Serialize(stream, settings); }