Using PerformanceCounters to target specific drives

眉间皱痕 提交于 2019-12-04 07:41:49

You should replace "_Total" with the appropriate drive number:

  diskRead.InstanceName = "0";

Should've checked that. You need to specify the name like "0 C: D:". Yikes.

Edit 2:

You can get the names with

    var cat = new System.Diagnostics.PerformanceCounterCategory("PhysicalDisk");
    var instNames = cat.GetInstanceNames();

And it is probaly safe to filter out the names that start with a number. (_Total is also in the list).

Use a specific InstanceName, not _Total. Use Perfmon.exe to find the instance names.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!