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