我试图发现什么样的网络连接,我连接。 它是WiFi或3G? 有没有办法做到这一点使用C#赢形式的.NET 2.0或4.0吗?
foreach (NetworkInterface adapter in adapters)
{
if (adapter.OperationalStatus == OperationalStatus.Up)
{
if (adapter.NetworkInterfaceType == NetworkInterfaceType.Wireless80211)
{
lblNetworkType.Text = "you are using WiFi";
break;
}
else if (adapter.NetworkInterfaceType == NetworkInterfaceType.Ppp)
{
lblNetworkType.Text = "you are using 3G or ADSL or Dialup";
break;
}
else if (adapter.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
{
lblNetworkType.Text = "you are using Ethernet";
break;
}
}
}