Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 总是得到;“访问被拒绝”;调用FileOpenPicker.PickSingleFileAndContinue()时_C# - Fatal编程技术网

C# 总是得到;“访问被拒绝”;调用FileOpenPicker.PickSingleFileAndContinue()时

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.PickSingleFileAndContinue为我的WP 8.1应用程序编写代码时遇到了问题。我所做的只是在继承自Page类的类中的onload方法中运行以下代码

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。无论如何,感谢您尝试帮助。