i have a listbox, and i want to save the items into an xml file.
this is the code to save:
XmlSerializer serializer = new XmlSerializer(typeof(string));
TextWriter tw = new StreamWriter("C:\\Users\\Lifebook\\Desktop\\Usage Profiles.txt");
for (int i = 0; i <= lstUsageProfile.Items.Count - 1; i++)
catch (Exception ex)
This is the output of the xml
this line is repeated for every node in the list box.
to save them it's no problem, but then i want to load them (for the next user who is working on the program)
but i can't load them up and put them back in the list box and removing the xml tags created by default.
after that link, i improved my code to:
XmlSerializer deserializer = new XmlSerializer(typeof(List<string>));
TextReader textReader = new StreamReader("C:\\Users\\Lifebook\\Desktop\\Usage Profiles.txt");
up = (List<string>)deserializer.Deserialize(textReader);
and i'm getting this error
There is an error in XML document (2, 2).