public void SaveData(Ksiegarnia ksiegarnia) { if (XmlFile.Exists) { XmlFile.Delete(); } Stream stream = new FileStream(XmlFile.FullName, FileMode.Create); Serializer.Serialize(stream, ksiegarnia); stream.Close(); }
public Ksiegarnia Deserialize() { Ksiegarnia result = null; if (XmlFile.Exists) { using (TextReader textReader = new StreamReader(XmlFile.FullName)) { result = (Ksiegarnia)Serializer.Deserialize(textReader); textReader.Close(); } } else { throw new IOException(); } return(result); }