0

Possible Duplicate:
List the IP Address of all computers connected to a single LAN

Can anyone please tell me exactly how to get the list of IP addresses of the PCs connected in a LAN? I got tired googling it because the answers are very confusing.

Please tell me how to exactly get the list of ip addresses using c#.

Community
  • 1
  • 1
Mubarak Basha
  • 341
  • 1
  • 7
  • 17

1 Answers1

0

so you can select the specific address-types

IPHostEntry host;
string localIP = "?";
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
    if (ip.AddressFamily.ToString() == AddressFamily.InterNetwork)
    {
        localIP = ip.ToString();
    }
}
return localIP;
masterchris_99
  • 2,683
  • 7
  • 34
  • 55