FileOpenPicker == OpenFileDialog RRS feed

  • Question

  • I've found quite a number of posts on the FileOpenPicker, but I haven't found anything that walks me through what I need to accomplish.

    I'm writing a Windows 8 RT application that is similar to the existing Windows 7 application. In the Windows 7 application, the user can simply click File -> Open and select a file. For example, a .txt file in My Documents.

    In the Windows 8 RT application, I've created an Open File button in the Bottom App Bar. I've also added a File Open Picker Contract to my project (my right-clicking the project, and selecting Add -> New Item -> File Open Picker Contract). Last, I've double-clicked the Package.appxmanifest, opened the Declarations tab, and verified that File Open Picker is in the Supported Declarations.

    My question is: how do I hook all this up? I thought this would be as easy as creating a Open File button handler, and adding code something like the following:

    FileOpenPicker1 openPicker = new FileOpenPicker1();

    The Activate API requires a FileOpenPickerUI object. Where does that come from? Why is the XAML code generated when the FileOpenPicker1 contract not the UI for picking a file?

    Again, I'm hoping for a link that describes the project of implementing a File Picker for someone thinking in terms of a OpenFileDialog.



    Thursday, October 24, 2013 2:22 PM


  • You don't need the File Open Picker Contract for what you are doing. The contract allows your app to appear in pickers opened by other apps. You just need to new up a FileOpenPicker, set the file types you want, then tell it to pick the file or files.

    There is a code snippet in the FileOpenPicker class documentation as well as a full File picker sample demonstrating several scenarios and a Quickstart topic in the Accessing data and files docs (in the How To section linked at the top of this page)


    Thursday, October 24, 2013 2:31 PM