gpt4 book ai didi

c# - 调用 FileOpenPicker.PickSingleFileAndContinue() 时总是得到 "Access is denied"

转载 作者:太空宇宙 更新时间:2023-11-03 20:03:10 27 4
gpt4 key购买 nike

我在为我的 WP 8.1 应用程序编码时调用 FileOpenPicker.PickSingleFileAndContinue 时卡住了。我所做的只是在我的类中的 OnLoaded 方法中运行以下代码,该类继承自 Page 类。

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: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))\r\n at 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.

这就解决了问题。

关于c# - 调用 FileOpenPicker.PickSingleFileAndContinue() 时总是得到 "Access is denied",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25912319/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com