private void button2_Click(object sender, EventArgs e) { try { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Title = "Export album album"; saveFileDialog.Filter = "Files Xml (*.xml)|*.xml|All files (*.*)" + "|*.*"; if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { AlbumXmlSerialized.Serialize(data, saveFileDialog.FileName); } } catch (Exception x) { MessageBox.Show("Error : " + x.Message); } }
//Import Album private void albumToolStripMenuItem_Click(object sender, EventArgs e) { try { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = "Import album"; openFileDialog.Filter = "Files format Xml (*.xml)|*.xml" + "|All files (*.*)|*.*"; openFileDialog.Multiselect = false; if (openFileDialog.ShowDialog() == DialogResult.OK) { Album data = AlbumXmlSerialized.Deserialize(openFileDialog.FileName); AlbumForm albumForm = new AlbumForm(data); albumForm.MdiParent = this; albumForm.Show(); } } catch (Exception x) { MessageBox.Show("Error : " + x.Message); } }