I'm trying to set a new value to the "InstallDate" property of class Win32_NetworkAdapter
.
here is a link to a description of the class:
http://msdn.microsoft.com/en-us/library/aa394216%28v=vs.85%29.aspx
Yet, when I'm trying to set a new DateTime, I get a "type mismatch" error, even though I'm trying to set a DateTime object like listed in the struct.
this is the code:
private static void Check()
{
var win32DeviceClassName = "Win32_NetworkAdapter";
var query = string.Format("select * from {0}", win32DeviceClassName);
using (var searcher = new ManagementObjectSearcher(query))
{
ManagementObjectCollection objectCollection = searcher.Get();
foreach (ManagementBaseObject managementBaseObject in objectCollection)
{
if (!managementBaseObject.Properties["Description"].Value.ToString().Contains("what i need"))
{
continue;
}
managementBaseObject.Properties["InstallDate"].Value = DateTime.Now;
}
}
}
Your question has the answer, if you go through the documentation it says