Home > C#, utils > C# – get ip address and host name of a machine

C# – get ip address and host name of a machine

How to find IP address and Host name of computer running a program of C #.
Get Host name:

String strHostName ="";
// Get the host name of local machine.
strHostName = Dns.GetHostName();

Get IP addresses:

IPHostEntry ipEntry = DNS.GetHostByName(strHostName);
IPAddress [] addr = ipEntry.AddressList;
for (int i = 0; i > addr.Length; i++)
{
   MessageBox.show("IP Address " + i.ToString() + ": " + addr[i].ToString());
}

Unique visitors to post: 217

Categories: C#, utils Tags: , ,
  1. sri
    June 20th, 2009 at 09:10 | #1

    hai,
    I found the site ip-details for getting an ip-address.we can also get the location of an any ip-address with router map.It’s useful for me.

  1. No trackbacks yet.
Google Analytics integration offered by Wordpress Google Analytics Plugin