This sample shows how to access files and folders by letting the user choose them through the file pickers and how to save a file so that the user can specify the name, file type, and location of a file to save. This sample uses Windows.Storage.Pickers and Windows.Storage API.

Note  This sample was created using one of the universal app templates available in Visual Studio. It shows how its solution is structured so it can run on both Windows 8.1 and Windows Phone 8.1. For more info about how to build apps that target Windows and Windows Phone with Visual Studio, see Build apps that target Windows and Windows Phone 8.1 by using Visual Studio.

The sample demonstrates these tasks:

  1. Let the user pick one file to access

    Uses the FileOpenPicker.PickSingleFileAsync method to call a file picker window and let the user pick a single file. For a walkthrough of this task, see Quickstart: accessing files with file pickers.

  2. Let the user pick multiple files to access

    Uses the FileOpenPicker.PickMultipleFilesAsync method to call a file picker window and let the user pick multiple files. For a walkthrough of this task, see Quickstart: accessing files with file pickers.

  3. Let the user pick one folder to access

    Uses the FolderPicker.PickSingleFolderAsync method to call a file picker window and let the user pick multiple files. For a walkthrough of this task, see Quickstart: accessing files with file pickers.

  4. Let the user save a file and specify the name, file type, and/or save location

    Uses the FileSavePicker.PickSaveFileAsync method to call a file picker window and let the user pick multiple files. For a walkthrough of this task, see How to save files through file pickers.

  5. Let the user pick a locally cached file to access

    The user may choose access a file that is provided by another app (the providing app) that participates in the Cached File Updater contract. Like the first scenario, this scenario uses the FileOpenPicker to access these files and to show how the providing app (the File picker contracts sample) can interact with the user through the file picker if necessary, for example if credentials are required to access the file.

    Note  This scenario requires the File picker contracts sample.

  6. Let the user save a locally cached file

    The user may choose save a file that was provided by another app (the providing app) that participates in the Cached File Updater contract. This scenario uses the FileSavePicker and the CachedFileManager to let the user save a file to another app (the File picker contracts sample) and how the providing app can interact with the user through the file picker if necessary, for example if there is a version conflict.

    Note  This scenario requires the File picker contracts sample.

To learn more about accessing and saving files and folders through file pickers, see Guidelines and checklist for file pickers.

To obtain an evaluation copy of Windows 8.1, go to Windows 8.1.

To obtain an evaluation copy of Microsoft Visual Studio 2013, go to Visual Studio 2013.

Note  For Windows 8 app samples, download the Windows 8 app samples pack. The samples in the Windows 8 app samples pack will build and run only on Microsoft Visual Studio 2012.

Related topics

Windows 8 app samples
Related samples
File access sample
Using a Blob to save and load content sample
File and folder thumbnail sample
File picker contracts sample

Related technologies

Windows.Storage.Pickers namespace

Operating system requirements

Client
Windows 8.1
Server
Windows Server 2012 R2
Phone
Windows Phone 8.1

Build the sample

  1. Start Microsoft Visual Studio 2013 Update 2 and select File > Open > Project/Solution.
  2. Go to the directory to which you unzipped the sample. Then go to the subdirectory named for the sample and double-click the Visual Studio 2013 Update 2 Solution (.sln) file.
  3. Follow the steps for the version of the sample you want:
    • To build the Windows version of the sample:

      1. Select FilePicker.Windows in Solution Explorer.
      2. Press Ctrl+Shift+B, or use Build > Build Solution, or use Build > Build FilePicker.Windows.
    • To build the Windows Phone version of the sample:

      1. Select FilePicker.WindowsPhone in Solution Explorer.
      2. Press Ctrl+Shift+B or use Build > Build Solution or use Build > Build FilePicker.WindowsPhone.

Run the sample