to get IP_address

Sabarimahesh
Posted by Sabarimahesh under C# category on | Points: 40 | Views : 1244
public string GetLocalIPAddress()
{

string IPAdd= string.Empty;

System.Net.IPHostEntry hos = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());



foreach (System.Net.IPAdd ip in hos.AddressList)
{

if (ip.AddressFamily.ToString() == "InterNetwork")
{

IPAdd = ip.ToString();

}

}

return IPAdd;

}

Comments or Responses

Login to post response