共用方式為


StorageLibrary.AreFolderSuggestionsAvailableAsync 方法

定義

判斷是否有將具有內容的現有資料夾新增至 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

適用於