So I just want to build simple app in WPF for managing invoices in my company, but without SQL database.
I decided to use XML format. But whenever I try to save data to my created XML file, the previous data is being overwritten. I tried to use docs example, but again data has been overwritten. Don't know why but i can store only one instance of my class(one company). I tried also putting companies into List and the adding to the xml file, still not working.
Anyone have any ideas how to resolve this problem?
My klass company
public class Company()
{
public int Id_company;
public string Name_Company;
public void add_Company(int id_company, string name_company)
{
this.Id_company = id_company;
this.Name_Company = name_company;
}
}
}
Saving to XML tried to assign to a button in app
private void Button_Click(object sender, RoutedEventArgs e)
{
Company company1 = new Company();
company1.add_Company(1, "Company1");
System.Xml.Serialization.XmlSerializer writer =
new System.Xml.Serialization.XmlSerializer(typeof(Company));
System.IO.FileStream file = System.IO.File.Create(path);
writer.Serialize(file, company1);
file.Close();
writer.Serialize;
}