mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-31 22:35:11 +00:00
Fixed Issue 382.
This commit is contained in:
@@ -210,11 +210,20 @@ namespace OpenHardwareMonitor.Hardware.HDD {
|
|||||||
if (usageSensor != null) {
|
if (usageSensor != null) {
|
||||||
long totalSize = 0;
|
long totalSize = 0;
|
||||||
long totalFreeSpace = 0;
|
long totalFreeSpace = 0;
|
||||||
|
|
||||||
for (int i = 0; i < driveInfos.Length; i++) {
|
for (int i = 0; i < driveInfos.Length; i++) {
|
||||||
|
if (!driveInfos[i].IsReady)
|
||||||
|
continue;
|
||||||
|
try {
|
||||||
totalSize += driveInfos[i].TotalSize;
|
totalSize += driveInfos[i].TotalSize;
|
||||||
totalFreeSpace += driveInfos[i].TotalFreeSpace;
|
totalFreeSpace += driveInfos[i].TotalFreeSpace;
|
||||||
|
} catch (IOException) { } catch (UnauthorizedAccessException) { }
|
||||||
}
|
}
|
||||||
|
if (totalSize > 0) {
|
||||||
usageSensor.Value = 100.0f - (100.0f * totalFreeSpace) / totalSize;
|
usageSensor.Value = 100.0f - (100.0f * totalFreeSpace) / totalSize;
|
||||||
|
} else {
|
||||||
|
usageSensor.Value = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user