从特定进程获取字节 [英] Get byte from specific process
本文介绍了从特定进程获取字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我写这段代码:
PerformanceCounter pc = new PerformanceCounter( .NET CLR Networking, 接收的字节数, 系统);
Console.WriteLine(pc.RawValue);
Console.ReadLine();
为什么我收到错误:
System.InvalidOperationException:'计数器是单个实例,实例名称'系统'对此计数器类别无效。'
< b>我尝试了什么:
我试试这个链接:我不能
c# - 如何监控特定应用程序的网络带宽使用情况? - 堆栈溢出 [ ^ ]
解决方案
您可能需要使用其他类别网络接口 ,请看这里的答案:
网络 - 如何在C#中显示每秒接收的字节数 - 堆栈溢出 [ ^ ]
但这不是特定于流程特定的......
替代方案可能是使用 TCPView 实用程序并使用其输出,请参阅: TCPView for Windows - Windows Sysinternals | Microsoft Docs [ ^ ]
Hi
I write this code:
PerformanceCounter pc = new PerformanceCounter(".NET CLR Networking", "Bytes Received", "System" );
Console.WriteLine(pc.RawValue);
Console.ReadLine();
Why i get error:
System.InvalidOperationException: 'Counter is single instance, instance name 'System' is not valid for this counter category.'
What I have tried:
I try by this link: and i can't
c# - How to monitor the network bandwidth usage of a specific application? - Stack Overflow[^]
解决方案
You probably need to use another category 'Network Interface', see the answer here:
networking - How to display bytes received per second in C# - Stack Overflow[^]
But this is not process specific sadly ...
An alternative might be using the TCPView utility and using the output of that, see: TCPView for Windows - Windows Sysinternals | Microsoft Docs[^]
这篇关于从特定进程获取字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文