Exemple #1
0
 private void WriteBooks()
 {
     try
     {
         using (StreamWriter writeData = new StreamWriter("dataBooks.xml"))
         {
             XmlDictionarySerialization.Serialize(writeData, books);
         }
     }
     catch (IOException ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK);
     }
 }
Exemple #2
0
 public void ReadBooks()
 {
     if (!File.Exists("dataBooks.xml"))
     {
         return;
     }
     try
     {
         using (StreamReader read = new StreamReader("dataBooks.xml"))
         {
             XmlDictionarySerialization.Deserialize(read, books);
         }
     }
     catch (IOException ex)
     {
         MessageBox.Show(ex.ToString(), "Reading error", MessageBoxButtons.OK);
     }
 }