LK said:
Can PLEASE SOMEONE HELP me how to enumerate local network interfaces (i.e
ip
addresses, dns, etc.) with csharp.
I need the type of information that would come up when typing
ipconfig /all
at a command prompt.
Thank you soo much
You could use WMI. Try the following (remember to reference
System.Messaging.dll):
using System;
using System.Management;
public class App
{
public static void Main()
{
ManagementObjectSearcher mos =
new ManagementObjectSearcher("select * from
Win32_NetworkAdapterConfiguration");
ManagementObjectCollection adapters = mos.Get();
foreach(ManagementObject adapter in adapters)
{
String[] ipAddresses = (String[])adapter["IPAddress"];
foreach(String ipAddress in ipAddresses)
Console.WriteLine(ipAddress);
}
}
}
Check out [1] for information about the
Win32_NetworkAdapterConfiguration WMI Class.
/Joakim
[1]
http://msdn.microsoft.com/library/d...sdk/wmi/win32_networkadapterconfiguration.asp