mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-30 05:47:38 +00:00
Changed the HDD enumeration code to drop drives without smart support and without any non-zero-sized logical drives.
This commit is contained in:
parent
67354b4125
commit
97e0a9c86f
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user