Measuring traffic sent and received over Internet
How to measure the number of bytes sent and received while using the internet from VB.NET 开发者_开发问答2010 ?
Here's an example of code that grabs the number of bytes received by the first IPv4 interface .(I set a label to the number, but of course you can do whatever with the number.)
Dim ipv4Stats As System.Net.NetworkInformation.IPv4InterfaceStatistics
ipv4Stats = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces(0).GetIPv4Statistics
Label1.Text = ipv4Stats.BytesReceived.ToString
I guess if you wanted it to automagically update or something, you could tie it to a timer or something.
精彩评论