0

i want retrieve all local ip addresses which is connected to network...

I am doing this by following code

private string GetLocalIP()
{
        IPHostEntry host;
        string localip = "?";
        host = Dns.GetHostEntry(Dns.GetHostName());
        foreach( IPAddress ip in host.AddressList)
        {
        if(ip.AddressFamily== AddressFamily.InterNetwork)
        {
            localip = ip.ToString();
            listBoxIPS.Items.Add(localip);
            return ip.ToString();                
        }
        } return "127.0.0.1";
}

but it retrieves only my local ip address not others please help me how to get other local ip addresses thank you..

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364

1 Answers1

0

Try to use .NET classes Dns and IPAddress to convert Hostname into IP Address in C#.

For detail check this -

http://www.morgantechspace.com/2014/04/Get-List-of-Network-Computer-Names-in-C-Sharp.html

Systematix Infotech
  • 2,345
  • 1
  • 14
  • 31