Example #1
0
        public void SaveData(Ksiegarnia ksiegarnia)
        {
            if (XmlFile.Exists)
            {
                XmlFile.Delete();
            }

            Stream stream = new FileStream(XmlFile.FullName, FileMode.Create);

            Serializer.Serialize(stream, ksiegarnia);
            stream.Close();
        }
Example #2
0
        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);
        }