How to get a list of names of all currently available networks (wired and not)? By means of standard console programs, it seems, this is not achieved. Can someone give a code in C # or a library to tell what?

  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky ♦

1 answer 1

Try using ManagetWifiAPI for wifi, and for izernet you can try it like this

var address = NetworkInterface .GetAllNetworkInterfaces() .Where(i => i.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || i.NetworkInterfaceType == NetworkInterfaceType.Ethernet) .SelectMany(i => i.GetIPProperties().UnicastAddresses) .Where(a => a.Address.AddressFamily == AddressFamily.InterNetwork) .Select(a => a.Address.ToString()) .ToList(); 

If you call like this

  static void Main(string[] args) { Console.WriteLine(IPGlobalProperties.GetIPGlobalProperties().DomainName); } 

And you return "empty", then either you are not online or the network name is "empty" (I don’t know if this is possible). I have no idea anymore why this may be happening, maybe you need to create a separate question on this topic!

  • Do not tell me how to get the name? - Andrei
  • NetworkInterface has a property Name - Yury Bakharev
  • Network name it does not return for some reason. - Andrei
  • @ Andrew, maybe you mean this name IPGlobalProperties.GetIPGlobalProperties (). DomainName - Yury Bakharev
  • For some reason, the empty line - Andrei