Vanara icon indicating copy to clipboard operation
Vanara copied to clipboard

ShellItemPropertyStore do not update even if the property has already changed

Open zhuxb711 opened this issue 11 months ago • 5 comments

Describe the bug and how to reproduce

Make sure the application is running before you unlock the Bitlocker on D:\

  1. Check the BitlockerState: should be 6 -> Actual: 6
  2. Unlock the bitlocker: should not be 6 -> Actual: 6
  3. Lock it again: should be 6 -> Actual: 6

It will not change until you restart the application

What code is involved

// D:\\ is locked by bitlocker
using (ShellItem Item = new ShellItem("D:\\"))
using (ShellItemPropertyStore PropertyStore = Item.Properties)
{
    if (PropertyStore.TryGetValue(ReadOnlyPropertyStore.GetPropertyKeyFromName("System.Volume.BitLockerProtection"), out object RawObject))
    {
        if (int.TryParse(Convert.ToString(RawObject), out int BitlockerState))
        {
            // BitlockerState == 6 -> Locked
            // BitlockerState != 6 -> Unlocked or NoEncryption
        }
    }
}

Expected behavior ShellItemPropertyStore should change itself once Windows modify the property of the file/folder

Screenshots <None>

zhuxb711 avatar Jun 21 '23 10:06 zhuxb711