C# 总是得到;“访问被拒绝”;调用FileOpenPicker.PickSingleFileAndContinue()时
调用FileOpenPicker.PickSingleFileAndContinue为我的WP 8.1应用程序编写代码时遇到了问题。我所做的只是在继承自Page类的类中的onload方法中运行以下代码C# 总是得到;“访问被拒绝”;调用FileOpenPicker.PickSingleFileAndContinue()时,c#,C#,调用FileOpenPicker.PickSingleFileAndContinue为我的WP 8.1应用程序编写代码时遇到了问题。我所做的只是在继承自Page类的类中的onload方法中运行以下代码 FileOpenPicker openPicker = new FileOpenPicker(); openPicker.ViewMode = PickerViewMode.List; openPicker.SuggestedStartLocation = PickerLocationId.Pic
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.List;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".pdf");
openPicker.FileTypeFilter.Add(".PDF");
openPicker.PickSingleFileAndContinue();
调用PickSingleFileAndContinue()方法后,始终抛出一个异常,并显示以下消息:
“System.UnauthorizedAccessException:访问被拒绝。(来自
HRESULT:0x80070005(E_ACCESSDENIED))\r\n位于
Windows.Storage.Pickers.FileOpenPicker.PickSingleFileAndContinue()
我可能对代码做了一些错误,但是在哪里。任何人都得到了我的帮助。谢谢。来自MSDN的回答:
Your FileOpenPicker code is fine.
The problem is that you can't call it from your page load.
If you delay it a bit or (better) call it in response to user
action then your code snippet will work.
这就解决了问题。来自MSDN的回答:
Your FileOpenPicker code is fine.
The problem is that you can't call it from your page load.
If you delay it a bit or (better) call it in response to user
action then your code snippet will work.
这就解决了问题。试试看谢谢Soner,但不是,这是两种不同的情况。我只是双重确认了该方法只被调用过一次。那篇文章中的问题发生在Win 8/8.1平台上,而不是WP 8.1。无论如何,谢谢你的帮助。试试看谢谢Soner,但不,这两种情况不同耳鼻喉科病例。我刚刚双重确认该方法只被调用过一次。而该帖子中的问题发生在Win 8/8.1平台上,而不是WP 8.1。无论如何,感谢您尝试帮助。