示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Show the dialog and get result.
            MySerializer serializer = new MySerializer();

            Person person;

            string       fileName;
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK) // Test result.
            {
                fileName = openFileDialog1.FileName;


                StreamReader reader = new StreamReader(fileName);
                person = MySerializer.Deserialize(reader);
                reader.Close();

                this.textBoxName.Text        = person.Name;
                this.textBoxEmail.Text       = person.Email;
                this.richTextBoxAddress.Text = person.Address;
            }
            //Console.WriteLine(result); // <-- For debugging use.
        }