在Windows 2008 R2,资源监视器中的磁盘活动部分,我可以看到/写入文件读取的字节数。我怎样才能做到这一点的一个纲领性的方式,preferably使用C#(或Win32 API的)?我已经调查WMI和各种性能计数器,但是我想不通,如果有一些东西,适合我的需要。
In Windows 2008R2, in Resource Monitor in the Disk Activity section I can see the number of bytes read from/written into files. How can I do this in a programmatic manner, preferably using C# (or Win32 API)? I have looked into WMI and various performance counters, however I cannot figure out if there is something which suits my needs.
有关的柜台文件I / O都在逻辑磁盘
和物理磁盘
的对象。您可以在性能监视器来看看,看看有什么计数器可用。
The counters relating to file I/O are on the LogicalDisk
and PhysicalDisk
objects. Take a look in Perfmon to see what counters are available.
使用的PerformanceCounter 类在C#或 PDH API 在C / C ++。在我的经验,这些是更有效的比WMI - 尽管这可能不是在你的申请事项
Use the PerformanceCounter class in C# or the PDH API in C/C++. In my experience these are much more efficient than WMI - though this may not matter in your application.