FileOpenPicker class

Applies to Windows and Windows Phone

Represents a UI element that lets the user choose and open files.

Syntax


Public NotInheritable Class FileOpenPicker

Attributes

[Muse()]
[Version(0x06020000)]

Members

The FileOpenPicker class has these types of members:

Constructors

The FileOpenPicker class has these constructors.

ConstructorDescription
FileOpenPicker Creates a new instance of a FileOpenPicker.

 

Methods

The FileOpenPicker class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
PickMultipleFilesAndContinue Shows the file picker so that the user can pick multiple files, deactivating and the app and reactivating it when the operation is complete. (Windows Phone Store app)
PickMultipleFilesAsync Shows the file picker so that the user can pick multiple files. (Windows Store app)
PickSingleFileAndContinue Shows the file picker so that the user can pick one file, deactivating and the app and reactivating it when the operation is complete. (Windows Phone Store app)
PickSingleFileAsync Shows the file picker so that the user can pick one file. (Windows Store app)
PickSingleFileAsync(String) Shows the file picker so that the user can pick one file. (Windows Store app)
ResumePickSingleFileAsync Resumes the picking operation to retrieve the user-selected file if the user navigates away from the app after the picker operation has completed and the app is suspended.

 

Properties

The FileOpenPicker class has these properties.

PropertyAccess typeDescription

CommitButtonText

Read/writeGets or sets the label text of the file open picker's commit button.

ContinuationData

Read-onlyGets a set of values to be populated by the app before PickSingleFileAndContinue or PickMultipleFilesAndContinue operation that deactivates the app in order to provide context when the app is activated. (Windows Phone Store app)

FileTypeFilter

Read-onlyGets the collection of file types that the file open picker displays.

SettingsIdentifier

Read/writeGets or sets the settings identifier associated with the state of the file open picker.

SuggestedStartLocation

Read/writeGets or sets the initial location where the file open picker looks for files to present to the user.

ViewMode

Read/writeGets or sets the view mode that the file open picker uses to display items.

 

Remarks

To get started accessing files and folders file pickers, see Quickstart: Accessing files with file pickers.

To learn about using file pickers in Windows Phone Store apps, see How to continue your Windows Phone app after calling a file picker.

Important  In Windows 8 if you attempt to display the file picker while your app is snapped, the file picker will not be shown and an exception will be thrown. You can avoid this by making sure your app is not snapped, or by unsnapping it before you call the file picker. The following code examples and the File picker sample show you how. Note that Windows 8.1 does not define a specific snapped window size. Instead, users can resize apps to any width, down to the minimum. Therefore, if your app will deploy only on Windows 8.1, you can ignore the EnsureUnsnapped function and calls to it in this topic's example code.

Examples

The File picker sample demonstrates how to check whether the app is snapped, how to set file picker properties, and how to show a file picker so that the user can pick one file.

No code example is currently available or this language may not be supported.

For C#, the File picker sample demonstrates how to check whether your app is snapped in the EnsureUnsnapped method.


internal bool EnsureUnsnapped()
{
    // FilePicker APIs will not work if the application is in a snapped state.
    // If an app wants to show a FilePicker while snapped, it must attempt to unsnap first
    bool unsnapped = ((ApplicationView.Value != ApplicationViewState.Snapped) || ApplicationView.TryUnsnap());
    if (!unsnapped)
    {
        NotifyUser("Cannot unsnap the sample.", NotifyType.StatusMessage);
    }

    return unsnapped;
}


The File picker sample also demonstrates how to show a file picker so that the user can pick multiple files.

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.

No code example is currently available or this language may not be supported.

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8

Namespace

Windows.Storage.Pickers
Windows::Storage::Pickers [C++]

Metadata

Windows.winmd

See also

File picker sample
Quickstart: Accessing files with file pickers
How to continue your Windows Phone app after calling a file picker

 

 

Show:
© 2014 Microsoft