public static string GetLocalIP()
{
string _IP = null;
System.Net.IPHostEntry _IPHostEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());
foreach (System.Net.IPAddress _IPAddress in _IPHostEntry.AddressList)
{
if (_IPAddress.AddressFamily.ToString() == "InterNetwork")
{
_IP = _IPAddress.ToString();
}
}
return _IP;
}
转载于:https://www.cnblogs.com/samblog/archive/2012/04/01/2428783.html