views:

195

answers:

1

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.

+1  A: 

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.

Ben Challenor
Though, if anyone knows how to get a per-file breakdown of IO stats (as in resmon) I would also be interested.
Ben Challenor