private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (fdOpen.ShowDialog() == DialogResult.OK) { try { MLHeader ml = new MLHeader(fdOpen.FileName); this.CurrentHeader = ml; } catch (InvalidDataException) { MessageBox.Show("Failed to open the file you specified, The data was invalid!", "Open Failed!", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception) { MessageBox.Show("Failed to open the file you specified, An unknown error occured. Is the file open in another program?", "Open Failed!", MessageBoxButtons.OK, MessageBoxIcon.Error); } CurrentFile = fdOpen.FileName; } }
void RecentFile_Click(object sender, EventArgs e) { ToolStripMenuItem RecentFile = (ToolStripMenuItem)sender; string fullPath = (string)RecentFile.Tag; fdOpen.FileName = fullPath; try { MLHeader ml = new MLHeader(fdOpen.FileName); this.CurrentHeader = ml; } catch (InvalidDataException) { MessageBox.Show("Failed to open the file you specified, The data was invalid!", "Open Failed!", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception) { MessageBox.Show("Failed to open the file you specified, An unknown error occured. Is the file open in another program?", "Open Failed!", MessageBoxButtons.OK, MessageBoxIcon.Error); } CurrentFile = fdOpen.FileName; }