public void saveToXml() { var driver = new XElement("Driver"); if (File.Exists("Driver.xml") == true) { string input = File.ReadAllText("Driver.xml"); driver = XElement.Parse(input); } else { driver = new XElement("Driver"); } XElement newDriver = new XElement("Driver", new XElement("Name", Name), new XElement("Surname", Surname), new XElement("Fathername", Fathername), new XElement("Starts", DateStartReport.ToString("dd/MM/yyyy")), new XElement("Ends", DateEndReport.ToString("dd/MM/yyyy")), new XElement("Income", Income)); driver.Add(newDriver); driver.Save("Driver.xml"); }
public void saveToXml() { var transport = new XElement("Transport"); if (File.Exists("Transport.xml") == true) { string input = File.ReadAllText("Transport.xml"); transport = XElement.Parse(input); } else { transport = new XElement("Transport"); } XElement newTransport = new XElement("Transport", new XElement("Type", Type), new XElement("Starts", DateStartReport.ToString("dd/MM/yyyy")), new XElement("Ends", DateEndReport.ToString("dd/MM/yyyy")), new XElement("Income", Income)); transport.Add(newTransport); transport.Save("Transport.xml"); }