Skip to content

Commit

Permalink
Better use of OpenFileDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
benlye committed Jul 5, 2019
1 parent 3862b01 commit 90a3bfe
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions src/flash-multi/FlashMulti.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,30 +457,21 @@ private void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
private void ButtonBrowse_Click(object sender, EventArgs e)
{
// Create the file open dialog
OpenFileDialog openFileDialog = new OpenFileDialog
using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
// Title for the dialog
Title = "Choose file to flash",
openFileDialog.Title = "Choose file to flash";

// Filter for .bin files
Filter = ".bin File|*.bin"
};
openFileDialog.Filter = ".bin File|*.bin";

try
{
// Show the dialog
openFileDialog.ShowDialog();

// Set the text box to the selected file name
textFileName.Text = openFileDialog.FileName;
} catch (Exception ex)
{
MessageBox.Show(String.Format("Error selecting file: {0}", ex.Message), "Select File", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
// Set the text box to the selected file name
textFileName.Text = openFileDialog.FileName;
}
}

// Dispose the file open dialog
openFileDialog.Dispose();

// Check if the Upload button should be enabled yet
CheckControls();
}
Expand Down

0 comments on commit 90a3bfe

Please sign in to comment.