コード例 #1
0
        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();
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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.
            //
        }