diff --git a/Hardware/HDD/AbstractHarddrive.cs b/Hardware/HDD/AbstractHarddrive.cs index 3bcefb8..d1f10d8 100644 --- a/Hardware/HDD/AbstractHarddrive.cs +++ b/Hardware/HDD/AbstractHarddrive.cs @@ -69,9 +69,12 @@ namespace OpenHardwareMonitor.Hardware.HDD { foreach (string logicalDrive in logicalDrives) { try { DriveInfo di = new DriveInfo(logicalDrive); - if (di.TotalSize > 0) + if (di.TotalSize > 0) driveInfoList.Add(new DriveInfo(logicalDrive)); - } catch (ArgumentException) { } catch (IOException) { } + } catch (ArgumentException) { + } catch (IOException) { + } catch (UnauthorizedAccessException) { + } } driveInfos = driveInfoList.ToArray(); @@ -105,6 +108,23 @@ namespace OpenHardwareMonitor.Hardware.HDD { string[] logicalDrives = smart.GetLogicalDrives(driveIndex); if (logicalDrives == null || logicalDrives.Length == 0) return null; + + bool hasNonZeroSizeDrive = false; + foreach (string logicalDrive in logicalDrives) { + try { + DriveInfo di = new DriveInfo(logicalDrive); + if (di.TotalSize > 0) { + hasNonZeroSizeDrive = true; + break; + } + } catch (ArgumentException) { + } catch (IOException) { + } catch (UnauthorizedAccessException) { + } + } + + if (!hasNonZeroSizeDrive) + return null; } if (string.IsNullOrEmpty(name))