This is next step of my previous question.
I'm creating a C# WinForm Application which will display Network Activity (Bytes Received / Bytes Sent) for a given Process (For Example: Process name 's chrome.exe) and Speed in Megabits/s generated by the Process.
While using the Performance Counters IO Read Bytes/sec
and IO Read Bytes/sec
shows I/O read and write bytes instead of 'Send and Received Bytes'.
PS: I/O counts all File, Network, and Device I/Os bytes generated by a Process. But, I wants only Network Bytes generated by a particular Process.
I wanted to retrieve only Bytes Received and Bytes Sent. But, don't know what counters are used to get these bytes of a Process.
I have searched these links for this purpose but not useful:
- C# Resource Monitor get network activity values
- Retrieve process network usage
- Missing network sent/received
- Need "Processes with Network Activity" functionality in managed code - Like resmon.exe does it
Here is Process's Performance Counter code that tried:
PerformanceCounter bytesReceived = new PerformanceCounter("Process", "IO Read Bytes/sec");
PerformanceCounter bytesSent = new PerformanceCounter("Process", "IO Write Bytes/sec");
string ProcessName = "chrome";
bytesReceived.InstanceName = ProcessName;
bytesSent.InstanceName = ProcessName;
Question: How I can only get the Received and Sent Bytes generated by a Process for a network activity.