using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Xml.Serialization; namespace FLY.FeedbackRenZiJia.Common { /// /// 加热记录 /// public class HeatProfile { public int[] Heats; public static HeatProfile Load(string path) { try { using (Stream fStream = new FileStream(path, FileMode.Open)) { XmlSerializer xmlFormat = new XmlSerializer(typeof(HeatProfile));//创建XML序列化器,需要指定对象的类型 HeatProfile sp = (HeatProfile)xmlFormat.Deserialize(fStream); fStream.Dispose();//关闭文件 return sp; } } catch { return null; } } public void Save(string path) { using ( Stream fStream = new FileStream(path, FileMode.Create)) { XmlSerializer xmlFormat = new XmlSerializer(typeof(HeatProfile));//创建XML序列化器,需要指定对象的类型 xmlFormat.Serialize(fStream, this); fStream.Dispose();//关闭文件 } } } }