Monday 29 April 2013

Get list of network computer Names and IP Address using C#

using System.Net.NetworkInformation;
using System.Net;
NetworkBrowser nb1 = new NetworkBrowser();
string[] PCIP = new string[250];
string[] PCIP1 = new string[250];
int i = 0;
foreach (string pc in nb1.getNetworkComputers())
{
    PCIP[i] = pc;
   IPAddress[] addresslist = Dns.GetHostAddresses(pc);
    foreach (IPAddress address in addresslist)
   {
        PCIP1[i] = address.ToString();                       
    }
    i++;
}

Get list of network computer names using C#

//get Network Computers Name
// Use using System.Net.NetworkInformation;


using System.Net.NetworkInformation;
NetworkBrowser nb1 = new NetworkBrowser();
string[] PCIP = new string[250];
int i = 0;
foreach (string pc in nb1.getNetworkComputers())
{
    PCIP[i] = pc;
    i++;
}