Hi,
I didn't know that you were talking about WMI, The managed wrapper array is
not a .NET type and that's why it doesn't behave as I specified.
This array has a dictionary interface that allows you to access by name, but
it is only a wrapper. I have implemented a logicalDisk function and all the
keys exist, which one doesn't?
Also, I am checking the WMI extensions for .NET or the WMI browser and all
of them have a key, I am curious.
Cheers
Salva
"Matthias Heise" wrote:
Thanks, normally that works fine. But here the special case where I need it
and where it does not work as you mentioned:
code:
WqlObjectQuery objectQuery = new WqlObjectQuery("select * from
Win32_LogicalDisk");
ManagementObjectSearcher searcher = new
ManagementObjectSearcher(objectQuery);
foreach (ManagementObject logicalDisk in searcher.Get())
{
Console.WriteLine("{0} has a DriveType of {1}", logicalDisk["Name"],
logicalDisk["DriveType"]);
}
I have a documentation which keys exist for the variable logicalDisk[] but
for some drive types some keys have no value or the key does not exist. So I
need to know which key-value pairs the object has. A cast from
ManagementObject to SortedList is not possible.
Matthias