[英]Exception thrown: 'System.UnauthorizedAccessException' in mscorlib.ni.dll uwp
i Go the above error and i don't know why, when i called CreateFolderAsync() 我遇到上述错误,我不知道为什么,当我调用CreateFolderAsync()时
StorageFolder appInstalledFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
StorageFolder newFolder = await appInstalledFolder.CreateFolderAsync(ClientFolder, CreationCollisionOption.ReplaceExisting);
Activated Event Time Duration Thread
Exception thrown: 'System.UnauthorizedAccessException' in mscorlib.ni.dll ("Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))") 0.24s [13604] Worker Thread
I have set these capabilities: 我已经设置了以下功能:
<Capabilities>
<Capability Name="internetClient" />
<uap:Capability Name="removableStorage" />
</Capabilities>
Where is the problem: 问题出在哪儿:
Not use Windows.ApplicationModel.Package.Current.You can use 不使用Windows.ApplicationModel.Package.Current。可以使用
ApplicationData.Current.LocalFolder;
ApplicationData.Current have LocalFolder and LocalCache and the tempUse file or folder can put in LoacalCache and the AppData can write in LocalFolder. ApplicationData.Current具有LocalFolder和LocalCache,并且tempUse文件或文件夹可以放入LoacalCache中,而AppData可以在LocalFolder中写入。
If you need use the Users file or folder,you can use the FolderPicker or FilePicker to pick the folder and file. 如果需要使用“用户”文件或文件夹,则可以使用FolderPicker或FilePicker来选择文件夹和文件。
The StorageApplicationPermissions.FutureAccessList can remember the users folder and file ,but it should use token. StorageApplicationPermissions.FutureAccessList可以记住用户的文件夹和文件,但应使用令牌。
You can see https://msdn.microsoft.com/zh-cn/windows/uwp/files/quickstart-reading-and-writing-files 您可以看到https://msdn.microsoft.com/zh-cn/windows/uwp/files/quickstart-reading-and-writing-files
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.