i would like to ask how can i get the internet amount that being used by some application like streaming and etc. i would like to make a program using in C# and i don't how can i start it.... give some advice thanks
-
Do you mean you want to measure the bandwidth usage of a given application? – Klaus Byskov Pedersen Feb 14 '11 at 13:36
3 Answers
As a starting point I'd look at the WinSock API. You may find a way of pulling traffic information on a per process basis. If you want to see total network usage, I'd use the Performance Monitoring tools. I found this example from a web search:
private static void ShowNetworkTraffic()
{
PerformanceCounterCategory performanceCounterCategory = new PerformanceCounterCategory("Network Interface");
string instance = performanceCounterCategory.GetInstanceNames()[0]; // 1st NIC !
PerformanceCounter performanceCounterSent = new PerformanceCounter("Network Interface", "Bytes Sent/sec", instance);
PerformanceCounter performanceCounterReceived = new PerformanceCounter("Network Interface", "Bytes Received/sec", instance);
for (int i = 0; i < 10; i++)
{
Console.WriteLine("bytes sent: {0}k\tbytes received: {1}k", performanceCounterSent.NextValue() / 1024, performanceCounterReceived.NextValue() / 1024);
Thread.Sleep(500);
}
}

- 2,925
- 6
- 29
- 34

- 1,302
- 1
- 9
- 18
To the best of my knowledge, there exists no standard method to measure network bandwidth per-application. The most you can get with standard means is essentially what netstat
and perfmon
show. The only way to calculate per-application metrics is to write an NDIS filter driver, or use an existing filter driver such as WinPcap. But both ways you'll have to install a driver on every target machine.

- 19,370
- 5
- 54
- 56
Try this: How to calculate network bandwidth speed in c#
EDIT
Now that I understand the question better try looking at this other SO question
-
That article specifies how to show bandwith data for the entire computer (or rather network interface), not for a single application. – Hans Kesting Feb 14 '11 at 13:41
-