protected string GetFileName(OpenFileDialog Dlg) { string FileName=""; Dlg.InitialDirectory = "c:\\"; Dlg.Filter = "All files (*.*)|*.*"; Dlg.FilterIndex = 2; Dlg.RestoreDirectory = true; if (Dlg.ShowDialog() == DialogResult.OK) { try { FileName = Dlg.FileName.ToString(); if (!Dlg.Equals(null)) Dlg.Dispose(); } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); if (!Dlg.Equals(null)) Dlg.Dispose(); } } return FileName; }
public override bool Equals(object obj) { return(_openFileDialog.Equals(obj)); }