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); } }