public static void SaveCarsXml(string filename, ListOfCars carsToSave) { Stream stream = File.Open(filename, FileMode.Create); DataContractSerializer ser = new DataContractSerializer(typeof(ListOfCars)); ser.WriteObject(stream, carsToSave); stream.Close(); }
public static ListOfCars LoadCarsXml(string filename) { Stream stream = File.Open(filename, FileMode.Open); DataContractSerializer ser = new DataContractSerializer(typeof(ListOfCars)); ListOfCars listOfCars = new ListOfCars(); listOfCars = (ListOfCars)ser.ReadObject(stream); stream.Close(); return(listOfCars); }
public static ListOfCars LoadCarsXml(string filename) { Stream stream = File.Open(filename, FileMode.Open); DataContractSerializer ser = new DataContractSerializer(typeof(ListOfCars)); ListOfCars listOfCars = new ListOfCars(); listOfCars = (ListOfCars)ser.ReadObject(stream); stream.Close(); return listOfCars; }