private void btnLoad_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Database for animal shelter |*.thisisadatabaseforanimalshelter"; if (ofd.ShowDialog() == DialogResult.OK) { try { administration.Load(ofd.FileName); } catch (FileNotFoundException fileNotFoundException) { MessageBox.Show(fileNotFoundException.Message); } catch (FileLoadException flException) { MessageBox.Show(flException.Message); } catch (IOException ioException) { MessageBox.Show(ioException.Message); } RedrawItemsInAnimalListBoxes(); } }
private void btnLoad_Click(object sender, EventArgs e) { try { Administration.Load(fileName); } catch (ArgumentNullException ex) { MessageBox.Show(ex.Message); } catch (ArgumentException ex) { MessageBox.Show(ex.Message); } catch (PathTooLongException ex) { MessageBox.Show(ex.Message); } catch (FileNotFoundException ex) { MessageBox.Show(ex.Message); } finally { //update } }
private void btnLoad_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { string loadPath = openFileDialog1.FileName; try { admin.Load(loadPath); } catch (FileNotFoundException) { MessageBox.Show("Vul een correcte bestandsnaam in"); } catch (SerializationException) { MessageBox.Show("Kies een geldig bestand"); } } updateListBoxes(); }
private void loadToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); try { if (openFile.ShowDialog() == DialogResult.OK) { string pathOfOpenFile = openFile.FileName; administration.Load(pathOfOpenFile); UpdateGUI(); } } catch (ArgumentNullException arnull) { MessageBox.Show(arnull.Message); } catch (PathTooLongException pathlong) { MessageBox.Show(pathlong.Message); } catch (FileNotFoundException notfound) { MessageBox.Show(notfound.Message); } catch (ArgumentException argument) { MessageBox.Show(argument.Message); } catch (SerializationException serialize) { MessageBox.Show(serialize.Message); } catch (NullReferenceException refrence) { MessageBox.Show(refrence.Message); } }