locked
FileSavePicker Questions RRS feed

  • Question

  • I have a few questions about this API. I want to allow the user to use the FileSavePicker to select a place to save a files. From the picker I want to extract the path/filename and do a series of CreateFileAsync()'s and CopyAndReplaceAsync()'s to save multiple files in that folder. But since the user is allowed to navigate the file system, I need to know beforehand if the app is even capable of doing CopyAndReplaceAsync()'s into that folder. I understand this is determined by the capabilities of the App. In my case I have enabled the Pictures Library capability. So....

    1. Is there a way to force the SuggestedStartLocation so it doesn't get over-ridden by history, i.e. PickerLocationId.PicturesLibrary
    2. Is there a way to prevent the user from navigating around the system in the FileSavePicker?
    3. For the StorageFile object that's returned, is there a way to know if the app has write capabilities enabled for the containing folder?
    4. Or more specifically, how can I determine if the picked file is in the user's Pictures library or any subfolder of it?

    Thanks

    Thursday, November 14, 2013 5:37 PM

Answers

  • The FileSavePicker will return a file the app can save to. It cannot use other files nearby. If you want to choose a folder to save multiple files to then use the FolderPicker.

    The libraries capabilities are not relevant if you use the pickers. The point of both is to give the user control over where the app can write. Since the user controls the picker the app can user the user's full access to that location.

    If you want to limit the user to the PicturesLibrary and deny them the choice of using other locations then you'll need to write your own picker.

    1. No
    2. No
    3. You can call GetParentAsync on the StorageFolder to see what you get back
    4. The app shouldn't care.

    --rob

    Thursday, November 14, 2013 6:13 PM
    Moderator

All replies

  • The FileSavePicker will return a file the app can save to. It cannot use other files nearby. If you want to choose a folder to save multiple files to then use the FolderPicker.

    The libraries capabilities are not relevant if you use the pickers. The point of both is to give the user control over where the app can write. Since the user controls the picker the app can user the user's full access to that location.

    If you want to limit the user to the PicturesLibrary and deny them the choice of using other locations then you'll need to write your own picker.

    1. No
    2. No
    3. You can call GetParentAsync on the StorageFolder to see what you get back
    4. The app shouldn't care.

    --rob

    Thursday, November 14, 2013 6:13 PM
    Moderator
  • Thanks Rob.

    So in my app, there's a collection of images. In the FileSavePicker we allow them to specify saving all images into a single PDF document or multiple JPEG files. For the former, as you stated, we have no problem saving it anywhere. For the latter, we extract the StorageFile object's path and filename and attempt to write multiple images to multiple files appending each new filename with an index.

    GetParentAsync() returns just another StorageFolder and there's doesn't appear to be anything there I can grab on to to tell me what I need.

    The FolderPicker sounds interesting. I will look into that. but I'm concerned it's going to require a re-design of our experience a little. But while I'm doing that...

    If I get a StorageFolder object from KnownFolders.PicturesLibrary, can I get the full path of that folder? Because with that, I can do a StartsWith() on the path of the StorageFile returned from the picker.

    Thursday, November 14, 2013 6:59 PM