Questions tagged «network-interface»

3
如何获得网络接口及其正确的IPv4地址?
我需要知道如何使用其IPv4地址获取所有网络接口。或者只是无线和以太网。 要获取所有网络接口的详细信息,请使用以下命令: foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces()) { if(ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet) { Console.WriteLine(ni.Name); } } 并获取计算机的所有托管IPv4地址: IPAddress [] IPS = Dns.GetHostAddresses(Dns.GetHostName()); foreach (IPAddress ip in IPS) { if (ip.AddressFamily == AddressFamily.InterNetwork) { Console.WriteLine("IP address: " + ip); } } 但是,如何获取网络接口及其正确的ipv4地址?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.