关键词:
XmlSerializer
StreamWriter
T instance
保存xml文件
代码:
public static void SaveXML<T>(string xmlFilePath, T instance) { XmlSerializer xs = new XmlSerializer(typeof(T)); StreamWriter sw = new StreamWriter(xmlFilePath); xs.Serialize(sw,instance); sw.Close(); }