Monitor disk activity programmatically (Windows)
In Windows 2008R2, in Resource Monitor in the Disk Activity section I can see the number of bytes read fr开发者_StackOverflow中文版om/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.
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.
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.
精彩评论