如何使用 Win32 云过滤器 API 在重命名的文件夹中显示占位符同步图标?

How can be shown the placeholder sync icon in a renamed folder using Win32 Cloud Filter API?

我正在使用 Microsoft Cloud Filter API to manage placeholders in my local directory, and when I rename a folder its state icon isn't visually updated after I apply the CfSetInSyncState function to this folder. This folder contains a file that was previously copied from another placeholder from this cloned directory. I've applied several functions besides CfSetInSyncState as CfUpdatePlaceholder, CfSetPinState, CfRevertPlaceholder and CfConvertToPlaceholder 到文件夹,但同步图标未正确显示,我检查了占位符是否具有 CF_PLACEHOLDER_STATE_IN_SYNC 状态。在这种情况下,有什么方法可以正确设置同步图标吗?

重命名文件夹前正确显示同步状态图标。

同步重命名的文件夹后,同步状态图标未在视觉上更新。

您需要同时调用 CfSetInSyncState 和 CfSetPinState。 首先将文件设置为同步状态,然后相应地更新引脚状态。

在这种情况下,我可以正确显示占位符同步图标,使用 MoveFileW and CfUpdatePlaceholder 函数重命名文件夹两次。这里给大家介绍一下文件夹重命名两次的方法。

bool FolderRenameTrick(const std::wstring& folderPath)
{
    // Gets a nonexistent folder path
    std::wstring folderPathAux = GenerateAuxPath(folderPath);

    if (folderPathAux != L"")
    {
        bool renamed = false;
        
        // Renames the folder with MoveFileW method (auxiliary folder)
        if (MoveFile(folderPath.c_str(), folderPathAux.c_str())) 
        {
            // UpdatePlaceholder calls internally to CfUpdatePlaceholder (auxiliary folder)
            if (UpdatePlaceholder(folderPathAux)) 
            {
                renamed = true;
            }
        }

        if (renamed)
        {
            // Renames the folder with MoveFileW method (correct folder)
            if (MoveFile(folderPathAux.c_str(), folderPath.c_str()))
            {
                // UpdatePlaceholder calls internally to CfUpdatePlaceholder (correct folder)
                if (UpdatePlaceholder(folderPath))
                {
                    return true;
                }
            }
        }
    }

    return false;
}