简体   繁体   English

FileOpenPicker PickSingleFileAsync抛出UnauthorizedAccessException

[英]FileOpenPicker PickSingleFileAsync throws UnauthorizedAccessException

The following code is almost verbatim from the MSDN example for the FileOpenPicker class. 以下代码几乎逐字逐句来自FileOpenPicker类的MSDN示例。

FileOpenPicker picker = new FileOpenPicker();
picker.ViewMode = PickerViewMode.Thumbnail;
picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
picker.FileTypeFilter.Add(".png");
picker.FileTypeFilter.Add(".jpg");
picker.FileTypeFilter.Add(".jpeg");

StorageFile file = await picker.PickSingleFileAsync();

When I trigger it from a button I get the following exception from the last line: 当我从按钮触发它时,我从最后一行得到以下异常:

System.UnauthorizedAccessException System.UnauthorizedAccessException的
Access is denied. 访问被拒绝。 (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) (HRESULT异常:0x80070005(E_ACCESSDENIED))

I thought the idea of the FileOpenPicker in this usage was that I didn't need to ask the user for access permissions or specify any capabilities? 我认为在这种用法中FileOpenPicker的想法是我不需要询问用户访问权限或指定任何功能?

I set a breakpoint just before the call to PickSingleFileAsync() . 我在调用PickSingleFileAsync()之前设置了一个断点。 Turns out that two tapped events were being fired when pressing a TextBlock within a Border (both with the same Tapped event handler). 事实证明,当按下Border中的TextBlock时,两个tapped事件被触发(两者都使用相同的Tapped事件处理程序)。

The first call worked as expected, but subsequent call resulted in the UnauthorizedAccessException and would occur straight after the picker was displayed. 第一个调用按预期工作,但后续调用导致UnauthorizedAccessException,并且会在显示选择器后直接发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 FileOpenPicker引发UnauthorizedAccessException - FileOpenPicker throws UnauthorizedAccessException UWP app:FileOpenPicker PickSingleFileAsync()无法等待 - UWP app: FileOpenPicker PickSingleFileAsync() can't await 使用FileOpenPicker时出现UnauthorizedAccessException - UnauthorizedAccessException when using FileOpenPicker NamedPipeClientStream 在 Connect 上抛出 UnauthorizedAccessException - NamedPipeClientStream throws UnauthorizedAccessException on Connect 谷歌 API .NET 抛出 UnauthorizedAccessException - Google API .NET Throws UnauthorizedAccessException C# 注册表 SetValue 抛出 UnauthorizedAccessException - C# Registry SetValue throws UnauthorizedAccessException ContactManager.RequestStoreAsync()抛出System.UnauthorizedAccessException - ContactManager.RequestStoreAsync() throws System.UnauthorizedAccessException GetAccessControl抛出UnauthorizedAccessException访问SystemData目录 - GetAccessControl throws UnauthorizedAccessException accessing SystemData directory MemoryMappedFile.CreateFromFile始终抛出UnauthorizedAccessException - MemoryMappedFile.CreateFromFile always throws UnauthorizedAccessException 下载文件引发 UnauthorizedAccessException net core 2 - Downloading a file throws UnauthorizedAccessException net core 2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM