Skip to content
This repository was archived by the owner on Aug 23, 2025. It is now read-only.

Commit f3bf053

Browse files
committed
Version 1.5.1
Fixes error handling when removing a VM from issue #56
1 parent df9782d commit f3bf053

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

86BoxManager/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333

34-
[assembly: AssemblyVersion("1.5.0.0")]
35-
[assembly: AssemblyFileVersion("1.5.0.0")]
34+
[assembly: AssemblyVersion("1.5.1.0")]
35+
[assembly: AssemblyFileVersion("1.5.1.0")]

86BoxManager/frmMain.cs

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -899,24 +899,41 @@ private void VMRemove()
899899

900900
if (result1 == DialogResult.Yes)
901901
{
902-
lstVMs.Items.Remove(lstVMs.SelectedItems[0]);
903-
regkey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\86Box\Virtual Machines", true);
904-
regkey.DeleteValue(vm.Name);
905-
regkey.Close();
906-
907-
DialogResult result2 = MessageBox.Show("Would you like to delete the files of this virtual machine as well?", "Delete files", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
908-
if (result2 == DialogResult.No)
902+
try
909903
{
910-
MessageBox.Show("Virtual machine \"" + vm.Name + "\" was successfully removed. Its files are still there if you want to re-add it later.", "Virtual machine removed", MessageBoxButtons.OK, MessageBoxIcon.Information);
904+
lstVMs.Items.Remove(lstVMs.SelectedItems[0]);
905+
regkey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\86Box\Virtual Machines", true);
906+
regkey.DeleteValue(vm.Name);
907+
regkey.Close();
911908
}
912-
else if (result2 == DialogResult.Yes)
909+
catch(Exception ex) //Catches "regkey doesn't exist" exceptions and such
910+
{
911+
MessageBox.Show("Virtual machine \"" + vm.Name + "\" could not be removed due to the following error:\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error );
912+
return;
913+
}
914+
915+
DialogResult result2 = MessageBox.Show("Virtual machine \"" + vm.Name + "\" was successfully removed. Would you like to delete its files as well?", "Virtual machine removed", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
916+
if (result2 == DialogResult.Yes)
913917
{
914918
try
915919
{
916920
Directory.Delete(vm.Path, true);
917921
}
918-
catch (DirectoryNotFoundException) {/*Just ignore this for now*/}
919-
MessageBox.Show("Virtual machine \"" + vm.Name + "\" was successfully removed, along with its files.", "Virtual machine and files removed", MessageBoxButtons.OK, MessageBoxIcon.Information);
922+
catch (UnauthorizedAccessException) //Files are read-only or protected by privileges
923+
{
924+
MessageBox.Show("86Box Manager was unable to delete the files of this virtual machine, because they are set as read-only or you don't have sufficient privileges to delete them.\n\nMake sure the files are free for deletion, then remove them manually.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
925+
return;
926+
}
927+
catch (IOException) //Files are in use by another process
928+
{
929+
MessageBox.Show("86Box Manager was unable to delete the files of this virtual machine, because they are currently in use by another process.\n\nMake sure the files are free for deletion, then remove them manually.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
930+
return;
931+
}
932+
catch (Exception ex) { //Other exceptions
933+
MessageBox.Show("The following error occurred while trying to remove the files of this virtual machine:\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
934+
return;
935+
}
936+
MessageBox.Show("Files of virtual machine \"" + vm.Name + "\" were successfully deleted.", "Virtual machine files removed", MessageBoxButtons.OK, MessageBoxIcon.Information);
920937
}
921938
}
922939
}

0 commit comments

Comments
 (0)