sequentially save multiple files RRS feed

  • Question

  • Hi Everyone,

    I want to sequentially save multiple files. They all have distinct names and the user picks where to save them. It’s not known at compile-time how many files there will be. The PickSaveFileAsync method only allows picking one file at a time so I want to do something like the snipped below, which obviously causes an exception since the ith filepicker is not done when the i+1th goes off.

    for( unsigned int i = 0; i < files.size() ; ++i )

    // Initzialize filesavepicker    

    auto savePicker = ref new FileSavePicker();

    // (…)

    auto savetask = Concurrency::create_task( savePicker->PickSaveFileAsync() ).then(

    [this,i](Windows::Storage::StorageFile^ file) {// save the file … });

    // savetask.wait(); would cause error here


    So next I would try to do block until the file was saved but this would cause an error since Winrt does not allow blocking the UI-Thread.

    So before I try to hack around these issuses what is a nice way to do accomplish this? I don't want to use a Folderpicker since the user should be able to specify the names of the files or at least a common prefix to all files.

    Thanks for your help.

    Sunday, October 6, 2013 8:48 AM


  • Hi ch.b,

    Welcome to MSDN forum!

    According to your description, you want to sequentially save multiple files and you hope that the user should be able to specify the names of the files. And the user should specify the file path too. So I advise you to give your users prompt about how and where your users could enter names and paths about the files without pop up. And after this, you could use FileSavePicker to prompt your users to save these files in a loop with the "suggested*" properties set as the users has entered before.

    Here is a sample about SaveFilePicker, I hope it is helpful.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 7, 2013 7:25 AM