XML repeat Serialization Winforms C# RRS feed

  • Question

  • I need to do this https://youtu.be/GwAamiBq3uA and I could do it, bit I need to create some other text boxes and also read info of a XML file (but not the same last XML file) I have been tried that code but choosing the XML with a open file dialog, but It still the same last XML file
    Sunday, May 27, 2018 5:06 PM

All replies

  • Hi SebGM2018,

    Thanks for posting here.

    please Check below.

     private void buttonLoad_Click(object sender, EventArgs e)
                OpenFileDialog openFileDialog1 = new OpenFileDialog();
                Stream myStream = null;
                openFileDialog1.InitialDirectory = "\\";
                openFileDialog1.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
                openFileDialog1.FilterIndex = 2;
                openFileDialog1.RestoreDirectory = true;
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                        if ((myStream = openFileDialog1.OpenFile()) != null)
                            using (myStream)
                                XmlSerializer xs = new XmlSerializer(typeof(Information));
                                Information info = (Information)xs.Deserialize(myStream);
                                textBoxLoad1.Text = info.Data1;
                                textBoxLoad2.Text = info.Data2;
                                textBoxLoad3.Text = info.Data3;
                    catch (Exception ex)
                        MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 28, 2018 3:25 AM