Exemple #1
0
        public void Save(DDiarys oData)
        {
            FileStream fs = new FileStream(xmlPath, FileMode.Truncate, FileAccess.ReadWrite);

            XmlSerializerDDiarys.Serialize(fs, oData);
            fs.Close();
        }
Exemple #2
0
        private void LoadXml()
        {
            //DDiary d = new DDiary();
            //d.InputDateTime = new DateTime(2019, 3, 15);
            //d.Name = "20190315";
            //d.Content = "ceshi";
            //DDiarys demo = new DDiarys();
            //demo.Items.Add(d);
            //demo.Items.Add(d);
            //Save(demo);
            //Diarys = demo;

            try
            {
                FileStream fs = new FileStream(xmlPath, FileMode.Open, FileAccess.Read);
                Diarys = (DDiarys)XmlSerializerDDiarys.Deserialize(fs);
                fs.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Load xml error : " + ex.ToString());
            }
        }