FilePickerSelectedFilesArray FilePickerSelectedFilesArray FilePickerSelectedFilesArray FilePickerSelectedFilesArray Class

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

Syntax

Declaration

public sealed class FilePickerSelectedFilesArraypublic sealed class FilePickerSelectedFilesArrayPublic NotInheritable Class FilePickerSelectedFilesArraypublic sealed class FilePickerSelectedFilesArray

Remarks

When a call to the 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.

Examples

The File picker sample demonstrates how capture the FilePickerSelectedFilesArray (files in the example) of picked files after calling 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.";
}
openPicker.pickMultipleFilesAsync().then(function (files) {
    if (files.size > 0) {
        // Application now has read/write access to the picked file(s)
        var outputString = "Picked files:\n";
        for (var i = 0; i < files.size; i++) {
            outputString = outputString + files[i].name + "\n";
        }
        WinJS.log && WinJS.log(outputString, "sample", "status");
    } else {
        // The picker was dismissed with no selected file
        WinJS.log && WinJS.log("Operation cancelled.", "sample", "status");
    }
});

Properties summary

Gets the number of StorageFile objects in the collection.

Methods summary

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

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

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

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

Properties

  • Size
    Size
    Size
    Size

    Gets the number of StorageFile objects in the collection.

    public uint Size { get; }public uint Size { get; }Public ReadOnly Property Size As uintpublic uint Size { get; }

    Property Value

    • uint
      uint
      uint
      uint

      The number of StorageFile objects in the collection.

Methods

  • First()
    First()
    First()
    First()

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

    public IIterator<StorageFile> First()public IIterator<StorageFile> First()Public Function First() As IIterator( Of StorageFile )public IIterator<StorageFile> First()

    Returns

    • The iterator.

  • GetAt(UInt32)
    GetAt(UInt32)
    GetAt(UInt32)
    GetAt(UInt32)

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

    public StorageFile GetAt(UInt32 index)public StorageFile GetAt(UInt32 index)Public Function GetAt(index As UInt32) As StorageFilepublic StorageFile GetAt(UInt32 index)

    Parameters

    • index
      System.UInt32
      System.UInt32
      System.UInt32
      System.UInt32

      The zero-based index of the object to retrieve.

    Returns

  • GetMany(UInt32, StorageFile[])
    GetMany(UInt32, StorageFile[])
    GetMany(UInt32, StorageFile[])
    GetMany(UInt32, StorageFile[])

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

    public uint GetMany(UInt32 startIndex, StorageFile[] items)public uint GetMany(UInt32 startIndex, StorageFile[] items)Public Function GetMany(startIndex As UInt32, items As StorageFile[]) As uintpublic uint GetMany(UInt32 startIndex, StorageFile[] items)

    Parameters

    • startIndex
      System.UInt32
      System.UInt32
      System.UInt32
      System.UInt32

      The zero-based index of the start of the objects in the collection to return.

    • items
      Windows.Storage.StorageFile[]
      Windows.Storage.StorageFile[]
      Windows.Storage.StorageFile[]
      Windows.Storage.StorageFile[]

      The items in the collection that start at startIndex.

    Returns

    • uint
      uint
      uint
      uint

      The number of items returned.

  • IndexOf(StorageFile, UInt32)
    IndexOf(StorageFile, UInt32)
    IndexOf(StorageFile, UInt32)
    IndexOf(StorageFile, UInt32)

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

    public bool IndexOf(StorageFile value, UInt32 index)public bool IndexOf(StorageFile value, UInt32 index)Public Function IndexOf(value As StorageFile, index As UInt32) As boolpublic bool IndexOf(StorageFile value, UInt32 index)

    Parameters

    • value

      The object to find in the collection.

    • index
      System.UInt32
      System.UInt32
      System.UInt32
      System.UInt32

      The zero-based index of the object if found. Zero is returned if the object is not found.

    Returns

    • bool
      bool
      bool
      bool

      True if the object is found; otherwise false.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute

Details

Assembly

Windows.Storage.Pickers.dll