我已尝试使用此代码在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);
}
但Windows Phone 8.1不支持PickSingleFolderAsync
,而PickFolderAndContinue
是无效功能。
如何将文件夹添加到StorageApplicationPermissions.MostRecentlyUsedList
?
答案 0 :(得分:1)
根据MSDN File picker sample,您会注意到可以在PickFolderAndContinue回调方法(ContinueFolderPicker)上检索该文件夹。
以下是示例中的代码段:
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.";
}
}
希望这有帮助吗?