title: Getting Received and Sent Bytes generated by Process for Network Activity
body: <p>This is next step of my previous <a href="https://stackoverflow.com/q/57972891/5377037">question</a>.</p>
  
  <hr>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>While using the Performance Counters <code>IO Read Bytes/sec</code> and <code>IO Read Bytes/sec</code> shows I/O read and write bytes instead of <strong>'Send and Received Bytes'</strong>. </p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>I have searched these links for this purpose but not useful:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/48397626/c-sharp-resource-monitor-get-network-activity-values">C# Resource Monitor get network activity values</a></li>
  <li><a href="https://stackoverflow.com/questions/17026204/retrieve-process-network-usage">Retrieve process network usage</a></li>
  <li><a href="https://stackoverflow.com/questions/10188603/missing-network-sent-received">Missing network sent/received</a></li>
  <li><a href="https://stackoverflow.com/questions/3081619/need-processes-with-network-activity-functionality-in-managed-code-like-resm">Need &quot;Processes with Network Activity&quot; functionality in managed code - Like resmon.exe does it</a></li>
  </ul>
  
  <p>Here is Process's Performance Counter code that tried:</p>
  
  <pre><code>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;
  </code></pre>
  
  <p><strong>Question:</strong> How I can only get the Received and Sent Bytes generated by a Process for a network activity.</p>