FilePickerSelectedFilesArray クラス

定義

ファイル ピッカーを使用してユーザーが選択したストレージ ファイルのコレクションを表します。

public ref class FilePickerSelectedFilesArray sealed : IIterable<StorageFile ^>, IVectorView<StorageFile ^>
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
class FilePickerSelectedFilesArray final : IIterable<StorageFile>, IVectorView<StorageFile>
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class FilePickerSelectedFilesArray final : IIterable<StorageFile>, IVectorView<StorageFile>
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public sealed class FilePickerSelectedFilesArray : IEnumerable<StorageFile>, IReadOnlyList<StorageFile>
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class FilePickerSelectedFilesArray : IEnumerable<StorageFile>, IReadOnlyList<StorageFile>
Public NotInheritable Class FilePickerSelectedFilesArray
Implements IEnumerable(Of StorageFile), IReadOnlyList(Of StorageFile)
継承
Object Platform::Object IInspectable FilePickerSelectedFilesArray
属性
実装

Windows の要件

デバイス ファミリ
Windows 10 (10.0.10240.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v1.0 で導入)

ファイル ピッカーのサンプルでは、fileOpenPicker.pickMultipleFilesAsync を呼び出した後に、選択したファイルの filePickerSelectedFilesArray (filesこの例では) をキャプチャする方法を示します。

注意

ユーザーが 1 つのファイルを選択しているか、複数のファイルを選択しているかに関係なく、アプリがスナップされていないこと (または、マップされていない可能性がある) を常に確認し、ファイル ピッカーのプロパティを設定する必要があります。

IReadOnlyList<StorageFile> files = await openPicker.PickMultipleFilesAsync();
if (files.Count > 0)
{
    StringBuilder output = new StringBuilder("Picked files:\n");
    // Application now has read/write access to the picked file(s)
    foreach (StorageFile file in files)
    {
        output.Append(file.Name + "\n");
    }
    OutputTextBlock.Text = output.ToString();
}
else
{
    OutputTextBlock.Text = "Operation cancelled.";
}

注釈

fileOpenPicker.pickMultipleFilesAsync メソッドの呼び出しが正常に完了すると、ユーザーが選択したすべてのファイルを含む filePickerSelectedFilesArray オブジェクトが返されます。 この配列内の選択されたファイルは、 storageFile オブジェクトによって表されます。

コレクション メンバー リスト

JavaScript の場合、FilePickerSelectedFilesArray にはメンバーリストにメンバーが表示されます。 さらに、FilePickerSelectedFilesArray では、 長さ プロパティ、 Array.prototype のメンバー、およびインデックスを使用して項目にアクセスできます。

C# または Microsoft Visual Basic でのコレクションの列挙

FilePickerSelectedFilesArray は列挙可能であるため、C# の foreach などの言語固有の構文を使用してコレクション内の項目を列挙できます。 コンパイラによって型キャストが行われ、明示的に キャストする IEnumerable<StorageFile> 必要はありません。 GetEnumerator を呼び出す場合など、明示的にキャストする必要がある場合は、StorageFile 制約を使用して IEnumerable<T> にキャストします。

プロパティ

Size

コレクション内の StorageFile オブジェクトの数を取得します。

メソッド

First()

選択したファイルを表す StorageFile オブジェクトのコレクションを反復処理する反復子を取得します。

GetAt(UInt32)

コレクション内の指定したインデックス位置にある StorageFile オブジェクトを返します。

GetMany(UInt32, StorageFile[])

コレクション内の指定したインデックスから始まる StorageFile オブジェクトを取得します。

IndexOf(StorageFile, UInt32)

コレクション内の指定した StorageFile オブジェクトのインデックスを取得します。

適用対象

こちらもご覧ください