4

There is no such thing as ActualStartLocation in UWP when setting the folder to open the FileOpenPicker, and that is the reason for my question. There is a SuggestedStartLocation, but the Microsoft site clearly states:

"The SuggestedStartLocation is not always used as the start location for the file picker. To give the user a sense of consistency, the file picker remembers the last location that the user navigated to and will generally start at that location."

SuggestedStartLocation remembers where you were, and continues to open that same folder every time. As an example, add this code to the button click event in a UWP project:

FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null) {
    TextBlock1.Text = "Selected Photo: " + file.Name;
} else {
    TextBlock1.Text = "Operation cancelled.";
}

Now run the program and select a picture.

Close the program change the code to use MusicLibrary instead of PicturesLibrary.

Run the program again, and when you click the button, you'll be back in the PicturesLibrary, even though you asked to see music.

Is there a way to override this and force the location where the file picker will start? (ie: ActualStartLocation)

I am trying to make an app where the user selects a picture and a music file, and it would be nice if the picture picker always opened in the pictures folder and if the music picker always opened in the music folder.

ThePeter
  • 883
  • 1
  • 7
  • 15

1 Answers1

4

As you have known it is by design.

"The SuggestedStartLocation is not always used as the start location for the file picker. To give the user a sense of consistency, the file picker remembers the last location that the user navigated to and will generally start at that location."

When you using FileOpenPicker to pick a file, the PickerHost.exe will be lunched. The PickerHost is a system application. And it will record the latest location you visited. You could not change the record in your application. Currently, there is no such "ActualStartLocation" property to achieve you want. If you do want this feature, you are welcome to ask on UserVoice .

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36
  • Feature request added on [UserVoice](https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/18978676-create-actualstartlocation-in-fileopenpicker) . – ThePeter Apr 19 '17 at 13:46