I am trying to find out if there are volumes on my system that are flagged as dirty. In my approach I requested the information from the Win32_Volume class but not every drive contains information about the state of "DirtyBitSet". Am I overlooking something? Unfortunately using the fsutil dirty query command via the command line is not an option since the output is in the respective system language. Thank you in advance.
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2","SELECT * FROM Win32_Volume");
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("Name: {0}", queryObj["Name"] ?? "unknown");
Console.WriteLine("DriveLetter: {0}", queryObj["DriveLetter"] ?? "unknown");
Console.WriteLine("DirtyBitSet: {0}", queryObj["DirtyBitSet"] ?? "unknown"); //this one is inconsistent
Console.WriteLine();
}