加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 如何在Windows商店(WinRT)应用程序中启用DocumentsLibrary

发布时间:2020-12-15 17:41:21 所属栏目:百科 来源:网络整理
导读:我刚刚在Visual Studio中创建了一个新的空白XAML / C# Windows应用商店应用.我尝试使用以下代码在Documents文件夹中创建一个文件: // DEBUG ONLY:StorageFile file = await KnownFolders.DocumentsLibrary.CreateFileAsync("Hey lol.txt"); 但它抛出了这个
我刚刚在Visual Studio中创建了一个新的空白XAML / C# Windows应用商店应用.我尝试使用以下代码在Documents文件夹中创建一个文件:
// DEBUG ONLY:
StorageFile file = await KnownFolders.DocumentsLibrary.CreateFileAsync("Hey lol.txt");

但它抛出了这个异常(我预期):

WinRT information: Access to the specified location (DocumentsLibrary) requires a capability to be declared in the manifest.

哪个好.我期待它.所以我转到Package.appxmanifest并转到Capabilities选项卡,令我惊讶的是,没有列出“DocumentsLibrary”功能.

如果它不存在,我该如何启用它?

解决方法

看起来你的答案是 here.作者在VS2012中显示它,但是从VS2013的列表中删除,引用了MS策略来访问该特定文件夹.

[Although] this capability is gone just from the UI,you still can open appxmanifest source and manually add the capability. The result will probably be the same as before – failure of certification for individual developers,so you better stay away from this trick. Microsoft strongly recommend against using Documents Library capability,suggesting Folder and File Pickers instead.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读