List<string> ipList = new List<string>(); foreach (IPAddress _IPAddress in Dns.GetHostEntry(Dns.GetHostName()).AddressList) { if (_IPAddress.AddressFamily.ToString() == "InterNetwork") { ipList.Add(_IPAddress.ToString()); } }
原文:http://www.cnblogs.com/gaobing/p/3811974.html