我正在尝试检测我连接到哪种网络连接。是WiFi还是3G?有没有办法使用 c# win forms .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;
}
}
}