Friday, May 15, 2009

How to get IPAddress in .Net

public static string mGetIPAddress()
{
string strHostName = Dns.GetHostName();
string strIPAddress = "";

IPHostEntry iphostentry = Dns.GetHostEntry(strHostName);

foreach (IPAddress ipaddress in iphostentry.AddressList)
{
strIPAddress = ipaddress.ToString();
}
return strIPAddress;
}

No comments:

Post a Comment

 
Locations of visitors to this page