访问文件系统到我的应用程序 UWP

Access the file system to my application UWP

我使用 StorageFile、StorageFolder 类型,它们需要访问文件系统,因为文件未被用户打开:

StorageFile storageFile = await StorageFile.GetFileFromPathAsync(filePath);

我需要这样我才能授予用户访问我的应用程序文件系统的权限:

我该怎么做?

您的截图是应用的访问权限设置页面,添加broadFileSystemAccess能力后,您的应用将显示在列表中,您还需要在文件系统设置页面手动启用广泛的文件系统。获取设置页面,可在设置应用首页搜索文件系统关键字。

如果您想快速访问该页面,可以使用以下方法。更多信息请参考Launch the Windows Settings app.

bool result = await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-broadfilesystemaccess")); 

更多信息请参考uwp File access permissions