Using the code below, you can reset all the properties of the network adapter, you need the Nameproperty:
ManagementObjectSearcher searcher = new ManagementObjectSearcher(
"SELECT * FROM Win32_NetworkAdapter");
foreach (ManagementObject adapter in searcher.Get())
{
StringBuilder propertiesDump = new StringBuilder();
foreach (var property in adapter.Properties)
{
propertiesDump.AppendFormat(
"{0} == {1}{2}",
property.Name,
property.Value,
Environment.NewLine);
}
}
OR just using LINQ (add using System.Linq):
foreach (ManagementObject adapter in searcher.Get())
{
string adapterName = adapter.Properties
.Cast<PropertyData>()
.Single(p => p.Name == "Name")
.Value.ToString();
}
PS: Also remember that you have a typo in the WMI request - forgot rin Adapter: Win32_NetworkAdapte_r _
source
share