Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How could I know whether a program currently using internet at a point in time, in Windows, using C#?
I've tried using Windows "netstat" commands like "netstat -no", but the connection state is shown "ESTABLISHED" even when the program is not transmitting or receiving any network data.
Is there any other ways to know this in C#?

Please give me a solution.
Thanks in advance.
Posted
Updated 23-Jan-15 5:00am
v2
Comments
Richard MacCutchan 23-Jan-15 11:47am    
You cannot know, since such activities take place in sub-second time frames.

1 solution

I am pretty sure it can be retrieved without fancy hacks. Consult Process Hacker's[^] code. What can be done in C++ in such case, can be also done in C#, with p/invoke at least...
WMI Win32_PerfRawData_PerfProc_Process[^] has IO properties, but thos include all IO activity.
What you can try is using performace counters, like described here: http://stackoverflow.com/questions/17026204/retrieve-process-network-usage[^].
 
Share this answer
 
Comments
Member 11138570 24-Jan-15 0:38am    
Thank you sir. Could you please help me on how to use Performance Counters to know the current network usage of a process?
Zoltán Zörgő 24-Jan-15 5:14am    
Have you read the solution proposed on the second link? It is all about that.
Member 11138570 25-Jan-15 0:44am    
Yes sir, I've read it. But it gives the whole I/O read/write statistics. I want only the network usage. How could I retrieve only the network usage of a process?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900