UWP KnownFolders.PicturesLibrary访问被禁止:System.UnauthorizedAccessException: Access is denied.
问题描述
在UWP应用中,试图访问图片文件夹(C:\Users[用户名xxx]\Pictures)下的一个文件时出现了错误:
StorageFolder picturesFolder = KnownFolders.PicturesLibrary;
错误描述:
System.UnauthorizedAccessException: 'Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))'
解决方案
在解决方案中双击 Package.appmanifest,然后在功能标签中勾选图片库(Pictures Library)
参考链接
https://stackoverflow.com/questions/53200799/knownfolders-pictureslibrary-access-is-denied
https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/tree-view#pictures-and-music-library-tree-view