Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a doubt on my code,how to all system ip address and udp port numbers and display in Combo box using c# in windows application. I tried but i don't get correct output.
I got error Message
C#
No such host is known


Please Help

What I have tried:

C#
    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;

    netUtility.Start();
    StreamReader streanreader = new StreamReader (netUtility.StandardOutput.BaseStream, netUtility.StandardOutput.CurrentEncoding);
    string line = "";


    while ((line = streanreader.ReadLine()) != null)
    {
        if (line.StartsWith("\\"))
        {

            string myIP = Convert.ToString(System.Net.Dns.GetHostEntry(line.Substring(2).Substring(0, line.Substring(2).IndexOf(" ")).ToUpper()).AddressList[0].ToString());
            textclientip.Text=listBox1.Items.Add(myIP).ToString();
            comboBox1.Items.Add(myIP);
            //textclientip.Text = listBox1.Text;
        }
    }

    streanreader.Close();
    netUtility.WaitForExit(1000);

}
Posted
Updated 11-Mar-16 12:13pm
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900