Skip to content

Commit 9a908dd

Browse files
committed
Handle SetOnlineStatus exceptions (at the end of the test)
1 parent beb487d commit 9a908dd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

HardDiskValidator/MainForm.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,15 @@ private void PerformTest(int physicalDiskIndex, TestName testName)
331331
{
332332
if (Environment.OSVersion.Version.Major >= 6)
333333
{
334-
disk.SetOnlineStatus(true, false);
334+
try
335+
{
336+
disk.SetOnlineStatus(true, false);
337+
}
338+
catch
339+
{
340+
// This may happen if the disk disappeared from the system
341+
MessageBox.Show("Unable to set disk status back to online");
342+
}
335343
}
336344
disk.ReleaseLock();
337345
disk.UpdateProperties();

0 commit comments

Comments
 (0)