Beispiel #1
0
        private void materialRaisedButton3_Click(object sender, EventArgs e)
        {
            BinaryFormatter formatter = new BinaryFormatter();

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string    path  = openFileDialog1.FileName;
                SvitKrasy item2 = null;
                using (var stream = new FileStream(path, FileMode.Open))
                {
                    item2 = (SvitKrasy)formatter.Deserialize(stream);
                    MessageBox.Show(item2.ToString());
                }
            }
        }
Beispiel #2
0
        private void materialRaisedButton1_Click(object sender, EventArgs e)
        {
            string    discount = comboBox1.Text;
            string    color    = comboBox2.Text;
            DateTime  date     = dateTimePicker1.Value;
            string    stones   = materialSingleLineTextField1.Text;
            SvitKrasy sv       = new SvitKrasy(color, discount, date, stones);

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                BinaryFormatter formatter = new BinaryFormatter();

                var    text = sv;
                string path = saveFileDialog1.FileName;
                using (var stream = new FileStream(path + ".txt", FileMode.Create))
                {
                    formatter.Serialize(stream, text);
                }
            }
        }