BytesSentPersec and BytesTotalPersec of a network adapter is always 0
Closed this issue · 2 comments
Library version
10.1.1.1
OS & OS version
Windows 10 and 11, could also be on other windows version, too. But I have only Windows 11 on my machine.
Describe the bug
BytesSentPersec and BytesTotalPersec of a network adapter is always 0, no matter how many data are sent or received.
To Reproduce
The problem here is that the network adapter name from "SELECT * FROM Win32_NetworkAdapter WHERE PhysicalAdapter=True AND MACAddress IS NOT NULL" is with a #. See screenshot:
But if you try to read the BytesSentPerSec and BytesTotalPersec, the network name to match has changed with a _
See screenshot:
In the class HardwareInfoRetrieval.cs:564 you are already change ( with [ and ) with ], so I think you will also need to change a # to _ if they appear in the name otherwise it won't match and the values will always be 0
Expected behavior
BytesSentPersec and BytesTotalPersec should show the correct value
Thank you for the detailed research! I will try to fix it in the next few days.
https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.performancecounter.instancename
networkAdapter.Name.Replace('(', '[').Replace(')', ']').Replace('#', '_').Replace('\\', '_').Replace('/', '_');