batchForm.cs: Added try-catch block to handle file in use exceptions

- Added try-catch block to handle exceptions when importing batch
- Displayed error message and notification form if an exception occurs
This commit is contained in:
Nathan Woodburn 2023-06-15 16:21:13 +10:00
parent c3abd0b4de
commit 404a47ec79
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -637,6 +637,8 @@ namespace FireWallet
openFileDialog.Filter = "All Files|*.*";
openFileDialog.Title = "Open Batch";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
StreamReader sr = new StreamReader(openFileDialog.FileName);
string line;
@ -718,6 +720,13 @@ namespace FireWallet
}
}
sr.Dispose();
} catch (Exception ex)
{
AddLog("Error importing batch: " + ex.Message);
NotifyForm notifyForm = new NotifyForm("Error importing batch\nMake sure the file is in not in use");
notifyForm.ShowDialog();
notifyForm.Dispose();
}
}
}