简体   繁体   English

引发异常:mscorlib.ni.dll uwp中的“ System.UnauthorizedAccessException”

[英]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.

相关问题 抛出异常:mscorlib.ni.dll 中的“System.ArgumentNullException” - Exception thrown: 'System.ArgumentNullException' in mscorlib.ni.dll 如何修复mscorlib.ni.dll中抛出的异常:“ System.Runtime.InteropServices.COMException”? - how to fix Exception thrown: 'System.Runtime.InteropServices.COMException' in mscorlib.ni.dll? “ mscorlib.ni.dll中发生了&#39;System.ArgumentException&#39;类型的异常” - “An exception of type 'System.ArgumentException' occurred in mscorlib.ni.dll” mscorlib.dll中发生了未处理的“System.UnauthorizedAccessException”类型异常 - An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll mscorlib.dll 中的 System.UnauthorizedAccessException - System.UnauthorizedAccessException in mscorlib.dll mscorlib.ni.dll中发生类型&#39;System.InvalidOperationException&#39;的异常,但未处理 - Exception of type 'System.InvalidOperationException' occurred in mscorlib.ni.dll but was not handled mscorlib.ni.dll中发生类型为&#39;System.IO.FileNotFoundException&#39;的第一次机会异常-Windows Phone - A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll - windows phone mscorlib.ni.dll中发生类型&#39;System.Reflection.TargetInvocationException&#39;的异常,但未在用户代码中处理:Xamarin形式 - An exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll but was not handled in user code: in Xamarin Form mscorlib.ni.dll中的&#39;System.NotSupportedException&#39;内存流不可扩展 - 'System.NotSupportedException' in mscorlib.ni.dll Memory stream is not expandable System.Windows.ni.dll中发生类型为“ System.UnauthorizedAccessException”的第一次机会异常 - A first chance exception of type 'System.UnauthorizedAccessException' occurred in System.Windows.ni.dll
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM