Jaa


FilePickerSelectedFilesArray Class

Definition

Represents a collection of storage files that the user has selected by using a file picker.

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)
Inheritance
Object Platform::Object IInspectable FilePickerSelectedFilesArray
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Examples

The File picker sample demonstrates how capture the filePickerSelectedFilesArray (files in the example) of picked files after calling fileOpenPicker.pickMultipleFilesAsync.

Note

You should always make sure that your app is not snapped (or that it can be unsnapped) and set file picker properties regardless of whether the user is picking a single file or multiple 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.";
}

Remarks

When a call to the fileOpenPicker.pickMultipleFilesAsync method completes successfully, it returns a filePickerSelectedFilesArray object that contains all the files that were picked by the user. Picked files in this array are represented by storageFile objects.

Collection member lists

For JavaScript, FilePickerSelectedFilesArray has the members shown in the member lists. In addition, FilePickerSelectedFilesArray supports a length property, members of Array.prototype, and using an index to access items.

Enumerating the collection in C# or Microsoft Visual Basic

FilePickerSelectedFilesArray is enumerable, so you can use language-specific syntax such as foreach in C# to enumerate the items in the collection. The compiler does the type-casting for you and you won't need to cast to IEnumerable<StorageFile> explicitly. If you do need to cast explicitly, for example if you want to call GetEnumerator, cast to IEnumerable<T> with a StorageFile constraint.

Properties

Size

Gets the number of StorageFile objects in the collection.

Methods

First()

Retrieves an iterator that iterates through the collection of StorageFile objects that represent selected files.

GetAt(UInt32)

Returns the StorageFile object at the specified index in the collection.

GetMany(UInt32, StorageFile[])

Retrieves the StorageFile objects that start at the specified index in the collection.

IndexOf(StorageFile, UInt32)

Retrieves the index of a specified StorageFile object in the collection.

Applies to

See also