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
    }
}

Note

アプリのパッケージ マニフェストに picturesLibrary 機能を含めるのを忘れないでください。 マニフェストの機能の詳細については、「 アプリの機能宣言」を参照してください。

注釈

この機能が Windows のバージョンでサポートされていない場合、 メソッドは false を返します

適用対象