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

注意

不論使用者挑選單一檔案或多個檔案,您一律應該確定您的應用程式不會 (或無法解壓縮) 並設定檔案選擇器屬性。

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 也支援 length 屬性、 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 物件的索引。

適用於

另請參閱