public bool Import(string DGPath, out string msg, bool needShapeData = true, bool needControlData = false) { if (!SignXmlHelper.VerifyXml(DGPath)) { msg = "文件已被更改!"; return(false); } msg = ""; XmlSerializer xs = new XmlSerializer(typeof(SaveDataInfo)); using (Stream stream = new FileStream(DGPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { SaveDataInfo dataInfo = (xs.Deserialize(stream) as SaveDataInfo); if (needShapeData) { this.CopyShapes(dataInfo); } if (needControlData) { this.CopyControlParams(dataInfo); } } return(true); }
public void Save(string savePath) { SaveDataInfo data = this; XmlSerializer xs = new XmlSerializer(data.GetType()); using (Stream stream = new FileStream(savePath, FileMode.Create, FileAccess.Write, FileShare.Read)) { xs.Serialize(stream, data); } SignXmlHelper.SignXml(savePath); }