如何显示上传和下载带宽 [英] how to show uploading and downloading bandwidth

查看:51
本文介绍了如何显示上传和下载带宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

有谁知道如何使用c#根据网络速度找出每kb/秒上载多少带宽?
有谁知道如何使用c#根据网速找出正在下载多少kb/sec的带宽?
以及如何基于kb/sec限制带宽.

hi to all..

Does any body knows how to find out how much bandwidth is uploading per kb/sec based on net speed using c#?
Does any body knows how to find out how much bandwidth is downloading kb/sec based on net speed using c#?
and how to restrict that bandwidth based on kb/sec..
if anybody knows please let me know the solution..

推荐答案

要计算使用的带宽,必须使用System.Net.NetworkInformatio命名空间中的NetworkInterface类,并且像这样计算:-

To calculate the bandwidth in use you must use the NetworkInterface class in the System.Net.NetworkInformatio namespace, and calculate it like this:-

IPv4InterfaceStatistics stats = NetworkInterface.GetAllNetworkInterfaces()[0].GetIPv4Statistics();
            int bytesSentSpeed = 0;
            int bytesReceivedSpeed = 0;
            bytesSentSpeed = (int)(stats.BytesSent - bytesSentSpeed) / 1024;
            bytesReceivedSpeed = (int)(stats.BytesReceived - bytesReceivedSpeed) / 1024;



至于限制带宽,我认为在C#中是不可能的.

希望对您有帮助



AS far as limiting the bandwidth, I don''t think it is possible in C#.

Hope this helps


这篇关于如何显示上传和下载带宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆