Saturday, October 11, 2008

The Code to get IP address of the Current Machine?

public void UseDNS()
{
  string hostName = Dns.GetHostName();
  Console.WriteLine("Host Name = " + hostName);
  IPHostEntry local = Dns.GetHostByName(hostName);  
  foreach(IPAddress ipaddress in local.AddressList)
  {
  Console.WriteLine("IPAddress = " + ipaddress.ToString()); 
  }
}

No comments: