掌握C#基础用于获取网络接口的IP与MAC
发布时间
阅读量:
阅读量
获取IP
string hostInfo = Dns.GetHostName();
//IP地址
//System.Net.IPAddress[] addressList = Dns.GetHostByName(hostInfo).AddressList;这个过时
System.Net.IPAddress[] addressList = Dns.GetHostEntry(hostInfo).AddressList;
ip = addressList[0].ToString();
二:适用于多网卡配置的情况
foreach (NetworkInterface netInt in NetworkInterface.GetAllNetworkInterfaces())
{
IPInterfaceProperties property = netInt.GetIPProperties();
foreach (UnicastIPAddressInformation
全部评论 (0)
还没有任何评论哟~
