使用 UWP BroadFileSystemAccess 受限权限时无法读/写文件 [英] Can't read/write files when using UWP broadFileSystemAccess restricted permission

查看:37
本文介绍了使用 UWP BroadFileSystemAccess 受限权限时无法读/写文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个公司内部应用程序并尝试在本地和网络驱动器上读写文件.我添加了 broadFileSystemAccess 受限功能.我能够列出目录,但在尝试读取或写入任何文件时出现 System.UnauthorizedAccessException.

I'm building an internal company app and trying to read and write files on local and network drives. I have added the broadFileSystemAccess restricted capability. I am able to list directories, but I get System.UnauthorizedAccessException when trying to read or write any files.

我发现如果我还为我正在读取或写入的文件类型添加文件类型关联,那么它就可以工作.但是,这也意味着该应用会在 Windows 中注册以打开我不想要的那些文件类型.

I have found that if I also add file type associations for the types of files I am reading or writing, then it works. However, this also means that the app gets registered with Windows to open those file types, which I do not want.

// This line works once I enable broadFileSystemAccess.
StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(@"Path\to\folder");

// This line works only after I add a pdf file type association.
StorageFile file = await StorageFile.GetFileFromPathAsync(@"Path\to\file.pdf");

推荐答案

正如 Stefan Wick MSFT 所说,在添加 broadFileSystemAccess 功能后,您还需要在文件系统设置页面中手动启用广泛的文件系统.设置页面可以在设置应用首页搜索文件系统关键词.

As Stefan Wick MSFT said, after add broadFileSystemAccess capability, you also need to manually enable broad file system in File System setting page. For getting the setting page, you could search file system keywords in setting app home page.

这篇关于使用 UWP BroadFileSystemAccess 受限权限时无法读/写文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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