VB.NET - ip addresses of network computers - Asked By murtaza rampurawala on 01-Oct-12 06:57 AM

i want to get the ip addresses of computrers connected to a Lan network and list them in a combo box how can i accomplish this task please help thanks
Cos mos replied to murtaza rampurawala on 01-Oct-12 07:44 AM
using System.Diagnostics; 
using System.IO; 
//Gets the machine names that are connected on LAN 
Process netUtility = new Process(); 
netUtility.StartInfo.FileName = "net.exe"; 
netUtility.StartInfo.CreateNoWindow = true; 
netUtility.StartInfo.Arguments = "view"; 
netUtility.StartInfo.RedirectStandardOutput = true; 
netUtility.StartInfo.UseShellExecute = false; 
netUtility.StartInfo.RedirectStandardError = true; 
StreamReader streamReader = new StreamReader(netUtility.StandardOutput.BaseStream, netUtility.StandardOutput.CurrentEncoding); 
string line = ""; 
while ((line = streamReader.ReadLine()) != null) 

      if (line.StartsWith("\\")) 
           listBox1.Items.Add(line.Substring(2).Substring(0, line.Substring(2).IndexOf(" ")).ToUpper()); 

Jitendra Faye replied to murtaza rampurawala on 01-Oct-12 09:01 AM
Try this code-

Using System.net you can get this ,
and using the following

    //To get the local IP address
string sHostName = Dns.GetHostName ();
IPHostEntry ipE = Dns.GetHostByName (sHostName);
IPAddress [] IpA = ipE.AddressList;
for (int i = 0; i < IpA.Length; i++)
    Console.WriteLine ("IP Address {0}: {1} ", i, IpA[i].ToString ());

Hemanth Kumar replied to murtaza rampurawala on 02-Oct-12 02:10 AM
Murtaza ,

You need to get the all IP Addresses of NetWork Computers

Do like this
if (ip.AddressFamily.ToString() == "InterNetwork")