private void ButtonAddElement(object sender, RoutedEventArgs e) { try { var dlg = new Microsoft.Win32.OpenFileDialog(); var result = dlg?.ShowDialog(); _main.AddFromFile(dlg.FileName); } catch (Exception) { MessageBox.Show("Add error"); } finally { ErrorMsg(); } }
private void Add_FromFile_Click(object sender, RoutedEventArgs e) { try { Microsoft.Win32.OpenFileDialog Dialog = new Microsoft.Win32.OpenFileDialog(); if ((bool)Dialog.ShowDialog()) { MainCollection.AddFromFile(Dialog.FileName); } } catch (Exception ex) { MessageBox.Show("Add From File error: " + ex.Message); } finally { ErrorMsg(); } }