如何避免在 Windows 文件管理器根目录中显示存储提供程序同步根目录
How to avoid displaying a storage provider sync root in Windows File Manager root
我正在使用存储提供商和 Windows 云文件 API 创建一个文件系统。我想避免在 Windows 文件管理器中显示同步根:
这里是我用来注册同步根的代码:
string path = "C:\Users\User1\DAV\";
StorageProviderSyncRootInfo storageInfo = new StorageProviderSyncRootInfo();
storageInfo.Path = await StorageFolder.GetFolderFromPathAsync(path);
storageInfo.Id = syncRootId;
storageInfo.DisplayNameResource = "WebDAV Drive";
storageInfo.IconResource = "C:\Drive.ico";
storageInfo.Version = "1.0"
storageInfo.RecycleBinUri = new Uri("https://userfilesystem.com/recyclebin");
storageInfo.Context = CryptographicBuffer.ConvertStringToBinary(path, BinaryStringEncoding.Utf8);
storageInfo.HydrationPolicy = StorageProviderHydrationPolicy.Progressive;
storageInfo.HydrationPolicyModifier = StorageProviderHydrationPolicyModifier.AutoDehydrationAllowed | StorageProviderHydrationPolicyModifier.ValidationRequired;
storageInfo.PopulationPolicy = StorageProviderPopulationPolicy.Full;
storageInfo.InSyncPolicy =
StorageProviderInSyncPolicy.FileCreationTime | StorageProviderInSyncPolicy.DirectoryCreationTime |
StorageProviderInSyncPolicy.FileLastWriteTime | StorageProviderInSyncPolicy.DirectoryLastWriteTime |
StorageProviderInSyncPolicy.FileHiddenAttribute | StorageProviderInSyncPolicy.DirectoryHiddenAttribute |
StorageProviderInSyncPolicy.FileSystemAttribute | StorageProviderInSyncPolicy.DirectorySystemAttribute;
StorageProviderSyncRootManager.Register(storageInfo);
完整的代码可以在GitHub repository中找到。
如何使我的文件系统不显示在 Windows 文件管理器中的根级别?
根据 Integrate a Cloud Storage Provider 文章,您可以编辑您的同步根注册信息并将 HKCU\Software\Classes\CLSID\{<GUID>}\ System.IsPinnedToNameSpaceTree
值修改为 0。这将从资源管理器树中隐藏您的同步根文件夹。如果用户打开“显示所有文件夹”选项,他仍然可以看到它。
要找到您的 SyncRoot CLSID,您需要打开同步根注册管理器并找到您的注册条目:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SyncRootManager\<your sync root>\ NamespaceCLSID
我正在使用存储提供商和 Windows 云文件 API 创建一个文件系统。我想避免在 Windows 文件管理器中显示同步根:
这里是我用来注册同步根的代码:
string path = "C:\Users\User1\DAV\";
StorageProviderSyncRootInfo storageInfo = new StorageProviderSyncRootInfo();
storageInfo.Path = await StorageFolder.GetFolderFromPathAsync(path);
storageInfo.Id = syncRootId;
storageInfo.DisplayNameResource = "WebDAV Drive";
storageInfo.IconResource = "C:\Drive.ico";
storageInfo.Version = "1.0"
storageInfo.RecycleBinUri = new Uri("https://userfilesystem.com/recyclebin");
storageInfo.Context = CryptographicBuffer.ConvertStringToBinary(path, BinaryStringEncoding.Utf8);
storageInfo.HydrationPolicy = StorageProviderHydrationPolicy.Progressive;
storageInfo.HydrationPolicyModifier = StorageProviderHydrationPolicyModifier.AutoDehydrationAllowed | StorageProviderHydrationPolicyModifier.ValidationRequired;
storageInfo.PopulationPolicy = StorageProviderPopulationPolicy.Full;
storageInfo.InSyncPolicy =
StorageProviderInSyncPolicy.FileCreationTime | StorageProviderInSyncPolicy.DirectoryCreationTime |
StorageProviderInSyncPolicy.FileLastWriteTime | StorageProviderInSyncPolicy.DirectoryLastWriteTime |
StorageProviderInSyncPolicy.FileHiddenAttribute | StorageProviderInSyncPolicy.DirectoryHiddenAttribute |
StorageProviderInSyncPolicy.FileSystemAttribute | StorageProviderInSyncPolicy.DirectorySystemAttribute;
StorageProviderSyncRootManager.Register(storageInfo);
完整的代码可以在GitHub repository中找到。
如何使我的文件系统不显示在 Windows 文件管理器中的根级别?
根据 Integrate a Cloud Storage Provider 文章,您可以编辑您的同步根注册信息并将 HKCU\Software\Classes\CLSID\{<GUID>}\ System.IsPinnedToNameSpaceTree
值修改为 0。这将从资源管理器树中隐藏您的同步根文件夹。如果用户打开“显示所有文件夹”选项,他仍然可以看到它。
要找到您的 SyncRoot CLSID,您需要打开同步根注册管理器并找到您的注册条目:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SyncRootManager\<your sync root>\ NamespaceCLSID