日期:2014-05-18 浏览次数:20983 次
string ipAddr =""; string GetHostName = Dns.GetHostName(); StringBuilder ipAddrSB = new StringBuilder(); System.Net.IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(GetHostName); System.Net.IPAddress[] addr = ipEntry.AddressList; foreach (IPAddress ip in addr) { ipAddrSB.Append(ip + "|"); } if (ipAddrSB.ToString()[ipAddrSB.Length - 1] == '|') { ipAddr = ipAddrSB.ToString().Substring(0, ipAddrSB.Length - 1); } MessageBox.Show(ipAddr,"好长的IP地址啊");
fe80::d06a:4fd3:daf3:8ac2%11| fe80::8e9:1779:89e3:c836%26| 2002:761c:37c9::761c:37c9| 169.254.138.194| 118.28.55.201| 2001:0:4137:9e76:8e9:1779:89e3:c836