I got a problem synchronizing the "IP address and Description".
The objective is this:
Get the IP address and what is the description?
Example:
| Atheros Azx1234 Wireless Adapter |
|192.168.1.55 |
But the outcome is not what I expected...
This is my code feel free to try...
private void button1_Click(object sender, EventArgs e)
{
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
IPHostEntry host;
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (NetworkInterface adapter in interfaces)
{
foreach (IPAddress ip in host.AddressList)
{
if ((adapter.OperationalStatus.ToString() == "Up") && // I have a problem with this condition
(ip.AddressFamily == AddressFamily.InterNetwork))
{
MessageBox.Show(ip.ToString(), adapter.Description.ToString());
}
}
}
}
How can I fix this problem?