UWP 访问被拒绝 [英] UWP access denied

查看:33
本文介绍了UWP 访问被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我很难通过 UWP 应用打开文本文件.我已将应用程序权限设置为能够访问我的文档"中的文件和我的图片"等已知库的其他选项,但任何尝试打开不在这些位置的文件都会遇到拒绝访问"错误.通过浏览互联网,我知道这是一个已知问题,并已被问过几次,但所有线程似乎都得出结论,如果不让用户通过文件选择器访问这些文件(由于沙盒),您根本无法访问这些文件).例如,请参阅下面的线程:

Basically, I am having huge difficulty getting a text file to open by my UWP app. I have set the app permissions to be able to access files in 'my documents' and other options of known libraries like 'my pictures' but any attempt to open a file not located in these places is met by an 'Access Denied' error. From trawling the internet I know this is a known issue and has been asked a few times, but all threads seem to lead to the conclusion that you simply cannot access these files without getting the user to access it via the file picker (due to sandboxing). See thread below for example:

https://social.msdn.microsoft.com/Forums/en-US/2ab6e209-cad7-4254-a252-b8e752ea7d13/uwp-how-can-i-access-locally-stored-files-not-on-removable-storage?forum=WindowsIoT

我知道再次提出同样的问题并希望得到不同的回应听起来是徒劳的,但我知道这不可能是完整的答案.我知道这一点是因为我已经从商店下载了其他记事本应用程序(例如现代记事本)并且它们允许这种行为没有问题.他们是怎么做到的???

I know asking the same question again and hoping for a different response sounds futile but I know for a fact that this cannot be the whole answer. I know this because I have downloaded other notepad apps from the store (e.g. modern notepad) and they allow this behaviour with no issues. How are they doing this???

这几个月来一直让我发疯,我真的希望有人能帮忙

This has been driving me mad for months and I really hope someone can help

推荐答案

5 个月后...

看来微软现在已经添加了这个功能.只需将broadFileSystemAccess"功能添加到应用清单中,如下所述:https://docs.microsoft.com/en-us/windows/uwp/files/file-access-permissions

It appears Microsoft have now added the capability. Simply add the 'broadFileSystemAccess' capability to the app manifest as described here: https://docs.microsoft.com/en-us/windows/uwp/files/file-access-permissions

请注意,这在一定程度上仍然需要用户输入(用户必须在第一次运行应用程序时授予文件系统访问权限),但不需要文件/文件夹选择器 UI.

Note that this still requires user input to some extent (the user must grant permission to file system access on first run of the app) but that the file/folder picker UI is not needed.

我还没有真正尝试过这个,但听起来它应该可以完成这项工作.我希望它可以帮助人们将来参考这篇文章.

I haven't actually tried this yet but it sounds like it should do the job. I hope it helps people referring to this post in the future.

这篇关于UWP 访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆