CSharp examples for System.Xml:XML Serialization
Serialize To Xml File
using System.Xml.Serialization; using System.Xml; using System.Text; using System.IO;//w w w . ja v a 2 s.c o m using System; public class Main{ /// <summary> /// /// </summary> /// <param name="filePath"></param> /// <param name="obj"></param> public static void SerializeToXmlFile(string filePath, object obj) { var writer = new StreamWriter(filePath); var xmlSerial = new XmlSerializer(obj.GetType()); xmlSerial.Serialize(writer, obj); writer.Close(); } }