static string NetworkGateway() { try { string ip = null; foreach (NetworkInterface f in NetworkInterface.GetAllNetworkInterfaces()) { if (f.OperationalStatus == OperationalStatus.Up) { foreach (GatewayIPAddressInformation d in f.GetIPProperties().GatewayAddresses) { ip = d.Address.ToString(); } } } return(ip); }catch (Exception ex) { WifiScanner ws = new WifiScanner(); ws.CreateDebugFile("#Error : Exception while getting network gateway address" + ex.Message); return(null); } }
private static List <string> GetAvailableWifi() { try { List <string> networkList = new List <string>(); WlanClient client = new WlanClient(); foreach (WlanClient.WlanInterface wlanIface in client.Interfaces) { // Lists all networks with WEP security Wlan.WlanAvailableNetwork[] networks = wlanIface.GetAvailableNetworkList(0); foreach (Wlan.WlanAvailableNetwork network in networks) { Wlan.Dot11Ssid ssid = network.dot11Ssid; string networkname = Encoding.ASCII.GetString(ssid.SSID, 0, (int)ssid.SSIDLength); string strength = network.wlanSignalQuality.ToString(); //string SSID_label = "SSID = "; if (networkname != "") { networkList.Add(networkname.ToString() + " Strength= " + strength + "/100"); } } } if (networkList.Count > 0) { Console.WriteLine("Listing the available wifi"); Console.WriteLine("--------------------------"); foreach (var item in networkList) { // listBox_AvailableWifi.Items.Add(item); Console.WriteLine(item.ToString()); } } return(networkList); }catch (Exception ex) { WifiScanner ws = new WifiScanner(); ws.CreateDebugFile("#Error :Exception while getting available wifi " + ex.Message); return(null); } }