+ 1

Use XML serializer with custom extension (C#)

I want to save data in a file with the XML Serializer, and that the file with the saved information has a custom file extension, such as "abc".

5th May 2018, 1:43 AM
SebGM2018
SebGM2018 - avatar
6 Antworten
0
This is the code I tried `try { Information info = new Information (); info.Data = textboxdata1.Text; info.Data2 = textboxdata2.Text; info.Data3 = textboxdata3.Text; SaveXML.SaveData (info, "data.xml"); } catch (Exception ex) { MessageBox.Show (ex.Message);  } } private void Form1_Load (object sender, EventArgs e) {  if (File.Exist ("data.xml")) { XmlSerializer xs = new XmlSerializer (typeof (Information)); FileStream read = new FileStream ("data.xml, FileMode.Open, FileAccess.Read, FileShare.Read);   Information info = (Information) xs.Deserialize (read);  textboxData1.Text = info.Data1;  textboxdata2.Text = info.Data2;  textboxdata3.Text = info.Data3; ` Specifically, I want to know if you can replace the "xml" ending with a custom "abc" ending, and that it still have the same values ​​and that it works as such. Just like here SaveXML.SaveData (info, "data.xml"); Thanks for your attention.
5th May 2018, 1:43 AM
SebGM2018
SebGM2018 - avatar
0
Nice code. Can you post the code of the info class ?
5th May 2018, 7:27 AM
sneeze
sneeze - avatar
0
Ok, In a moment I do It, but have you tried To change the Extension?
5th May 2018, 2:13 PM
SebGM2018
SebGM2018 - avatar
0
Not yet. I will try as soon as i can.
5th May 2018, 2:17 PM
sneeze
sneeze - avatar
0
Ok thanks, just wait a minute
5th May 2018, 2:20 PM
SebGM2018
SebGM2018 - avatar
0
I am trying, to test it. Can you also post the code of SaveXML.SaveData ?
5th May 2018, 8:04 PM
sneeze
sneeze - avatar