Is there a way to determine which connection I am using? WiFi, 3G or Ethernet?

I am trying to determine which network connection I am connected to. Is it WiFi or 3G? is there any way to do this using c # win forms.net 2.0 or 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; } } } 
+5
c # networking winforms wifi 3g
source share
1 answer

Unfortunately, there is no “neat" way to do this as such. A 3G connection will look like an ADSL or dial-up connection (with a type of PPP network).

If you are sure that you will only be in WiFi / 3G, then you can check the information in the NetworkInterface class provided by GetAllNetworkInterfaces and consider it as 3G if the interface type is PPP. But, as I said, this is the same for other types of modem connection.

Edit: You may be lucky to find "3G", "HSPA", "HSDPA", "Dongle" in the name or description of the device. But that would be a “decent guess”, and not be absolutely sure.

+3
source share

All Articles