Cena Av
Cena Av

Reputation: 99

Get folder from FolderPicker in windows phone 8.1

I have tried this code to get a folder on Windows Phone.

    FolderPicker folderPicker = new FolderPicker();
    folderPicker.SuggestedStartLocation = PickerLocationId.Downloads;
    StorageFolder folder = await folderPicker.PickSingleFolderAsync();

    if (folder != null)
    {
        string Token = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList.Add(folder, folder.Name);

    }

But PickSingleFolderAsync is not supported in Windows Phone 8.1 and PickFolderAndContinue is a void function.

How can I add a folder to StorageApplicationPermissions.MostRecentlyUsedList ?

Upvotes: 1

Views: 163

Answers (1)

According to the MSDN File picker sample, you'll notice that the folder can be retrieved on PickFolderAndContinue callback method (ContinueFolderPicker).

Below is a code snippet from the sample:

public void ContinueFolderPicker(FolderPickerContinuationEventArgs args) 
    { 
        StorageFolder folder = args.Folder; 
        if (folder != null) 
        { 
            // Application now has read/write access to all contents in the picked folder (including other sub-folder contents) 
            StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder); 
            OutputTextBlock.Text = "Picked folder: " + folder.Name; 
        } 
        else 
        { 
            OutputTextBlock.Text = "Operation cancelled."; 
        } 
    } 

Hope this helps?

Upvotes: 1

Related Questions