【问题标题】:Get folder from FolderPicker in windows phone 8.1从 windows phone 8.1 中的 FolderPicker 获取文件夹
【发布时间】:2015-05-07 06:00:25
【问题描述】:

我已尝试使用此代码在 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);

    }

PickSingleFolderAsync 在 Windows Phone 8.1 中不受支持,PickFolderAndContinue 是一个 void 函数。

如何向StorageApplicationPermissions.MostRecentlyUsedList 添加文件夹?

【问题讨论】:

    标签: windows-phone-8.1


    【解决方案1】:

    根据MSDN File picker sample,您会注意到可以在 PickFolderAndContinue 回调方法(ContinueFolderPicker)上检索该文件夹。

    以下是示例中的代码 sn-p:

    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."; 
            } 
        } 
    

    希望这有帮助吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多