Skip to content

ShellItemChangeWatcher - Changed event is not raised for ChangeFilters.FolderDeleted #572

@omeryanar

Description

@omeryanar

Describe the bug and how to reproduce

Changed event is not raised after permanent delete (SHIFT+DELETE) of a folder. I tested on Windows 11 with explicitly setting ChangeFilters.FolderDeleted and then AllDiskEvents, and then AllEvents. In all three cases, Changed event is not raised for ChangeType equals to FolderDeleted.

I debugged ShellItemChangeWatcher and see that MessageFilter of WatcherNativeWindow is not called with correct parameters. I checked the code and MSDN documentation, and everything seems correct.

https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shchangenotifyregister

So, what do you think the problem might be? Where should I check?

What code is involved

ShellItemChangeWatcher shellItemChangeWatcher = new ShellItemChangeWatcher();
shellItemChangeWatcher.NotifyFilter = ChangeFilters.AllDiskEvents;
shellItemChangeWatcher.Changed += ShellItemChangeWatcher_Changed;

void ShellItemChangeWatcher_Changed(object sender, ShellItemChangeWatcher.ShellItemChangeEventArgs e)
{
if (e.ChangedItems.Length > 0)
{
Console.WriteLine($"ShellItemChangeWatcher: {e.ChangeType}: ");
foreach (var item in e.ChangedItems)
{
Console.WriteLine($"{item}");
}
}
}

shellItemChangeWatcher.Item = ShellFolder.Desktop;
shellItemChangeWatcher.IncludeChildren = true;
shellItemChangeWatcher.EnableRaisingEvents = true;

Expected behavior

After deleting a folder from the file system, Changed event is raised for e.ChangeType equals to FolderDeleted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions