StorageLibrary.AreFolderSuggestionsAvailableAsync 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
确定是否有建议将包含内容的现有文件夹添加到 StorageLibrary。
public:
virtual IAsyncOperation<bool> ^ AreFolderSuggestionsAvailableAsync() = AreFolderSuggestionsAvailableAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<bool> AreFolderSuggestionsAvailableAsync();
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<bool> AreFolderSuggestionsAvailableAsync();
function areFolderSuggestionsAvailableAsync()
Public Function AreFolderSuggestionsAvailableAsync () As IAsyncOperation(Of Boolean)
返回
如果存在文件夹建议,则为 True;否则为 False
- 属性
Windows 要求
设备系列 |
Windows 10 Fall Creators Update (在 10.0.16299.0 中引入)
|
API contract |
Windows.Foundation.UniversalApiContract (在 v5.0 中引入)
|
示例
此示例演示如何确定是否有任何建议的文件夹包含可添加到图片库的内容。
private async Task<StorageLibrary> SetupPicturesLibraryAsync()
{
if (this.picturesLibrary == null)
{
this.picturesLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Pictures);
this.picturesLibrary.DefinitionChanged += PicturesLibrary_DefinitionChanged;
}
return this.picturesLibrary;
}
private async void CheckForFolderSuggestions_Clicked(object sender, RoutedEventArgs e)
{
var library = await SetupPicturesLibraryAsync();
if (await library.AreFolderSuggestionsAvailableAsync())
{
// There are new folders that could be added to the library.
// Prompt the user to add one or more of them.
// Note that the RequestAddFolderAsync method returns only one folder.
// If the user adds multiple folders, only one will be returned.
// In this example, to keep track of all the added folders, the app can subscribe to the
// StorageLibrary.DefinitionChanged event by awaiting library.RequestAddFolderAsync();
// Launch the folder suggestion dialog
var folder = await library.RequestAddFolderAsync();
}
}
private void PicturesLibrary_DefinitionChanged(StorageLibrary sender, object args)
{
foreach (StorageFolder folder in sender.Folders)
{
// Do something with every folder in the library
}
}
注意
不要忘记在应用的包清单中包含 picturesLibrary 功能。 有关清单中的功能的详细信息,请参阅 应用功能声明。
注解
如果 Windows 版本不支持此功能,则 该方法将返回 false。