I need a way to get the current system network usage, up and down.
I found some on the net but they're not working out for me.
Thanks for your help
Code snippet:
private void timerPerf_Tick(object sender, EventArgs e)
{
if (!NetworkInterface.GetIsNetworkAvailable())
return;
NetworkInterface[] interfaces
= NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface ni in interfaces)
{
this.labelnetup.Text = " Bytes Sent: " + ni.GetIPv4Statistics().BytesSent;
this.labelnetdown.Text = " Bytes Rec: " + ni.GetIPv4Statistics().BytesReceived;
}
}
Here is the code for a windows form with timer.
Please see Report information from NetworkInterface: network statistics for a good sample program:
You can get the current system's network usage by working with PerformanceCounterCategory too:
Source: http://dotnet-snippets.com/snippet/show-network-traffic-sent-and-received/580