Example #1
0
        private void restore_btn_Click(object sender, EventArgs e)
        {
            XmlSerializer xs   = new XmlSerializer(typeof(Meau));
            StreamReader  sr   = new StreamReader(@"E:\Modren Academy\year 3\part 2\Data Stroage\serialization & dserialization\Meau.xml");
            Meau          meau = (Meau)xs.Deserialize(sr);

            Section_txt.Text     = meau.section;
            Name_txt.Text        = meau.name;
            description_txt.Text = meau.description;
            Price_txt.Text       = meau.price.ToString();
        }
Example #2
0
        private void Save_btn_Click(object sender, EventArgs e)
        {
            Meau meau = new Meau();

            meau.section     = Section_txt.Text;
            meau.name        = Name_txt.Text;
            meau.description = description_txt.Text;
            meau.price       = float.Parse(Price_txt.Text);
            XmlSerializer xs = new XmlSerializer(typeof(Meau));
            StreamWriter  sw = new StreamWriter(@"E:\Modren Academy\year 3\part 2\Data Stroage\serialization & dserialization\Meau.xml");

            xs.Serialize(sw, meau);
            MessageBox.Show("Data Saved.");
        }