static public void SerializeToXML(HistoryTemplate ht, String path) { XmlSerializer serializer = new XmlSerializer(typeof(HistoryTemplate)); TextWriter textWriter = new StreamWriter(path, false); serializer.Serialize(textWriter, ht); textWriter.Close(); }
static public HistoryTemplate DeserializeFromXML(String path) { XmlSerializer mySerializer = new XmlSerializer(typeof(HistoryTemplate)); FileStream myFileStream = new FileStream(path, FileMode.Open); HistoryTemplate ht = (HistoryTemplate)mySerializer.Deserialize(myFileStream); myFileStream.Close(); return(ht); }
public MainForm() { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); ht = new HistoryTemplate(); try{ string appPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\" + this.ht.fileName; this.ht = DeserializeFromXML(appPath); } catch (Exception e) {} LoadHistory(); // // TODO: Add constructor code after the InitializeComponent() call. // }