Мне нужно отобразить весь IP-адрес моей локальной сети в ListBox. Когда я пытаюсь связать его пустой.Показать все IP-адреса из локальной сети
// Код
Process netUtility = new Process();
netUtility.StartInfo.FileName = "net.exe";
netUtility.StartInfo.CreateNoWindow = true;
netUtility.StartInfo.RedirectStandardOutput = true;
netUtility.StartInfo.UseShellExecute = false;
netUtility.StartInfo.RedirectStandardError = true;
netUtility.Start();
StreamReader streamReader = new StreamReader(netUtility.StandardOutput.BaseStream);
string line = "";
while ((line = streamReader.ReadLine()) != null)
{
if (line.StartsWith("\\"))
{
ListBox1.Items.Add(line.Substring(2).Substring(0, line.Substring(2).IndexOf(" ")).ToUpper());
}
}
streamReader.Close();
netUtility.WaitForExit(1000);
Где я ошибаюсь?
Возможный дубликат, пожалуйста, смотрите по следующей ссылке, [http://stackoverflow.com/questions/965088/get-all-ips-in-the-same-network-as-my-computer][1] [1]: http://stackoverflow.com/questions/965088/get-all-ips-in-the-same-network-as-my-computer –