0

我为 Windows 商店制作了应用程序。在我将操作系统升级到 Windows 8.1 之前它运行良好。我尝试 FileOpenPicker 时出错:

未找到元素。(Исключение из HRESULT: 0x80070490)

这是堆栈跟踪:

在 Windows.Storage.Pickers.FileOpenPicker.PickSingleFileAsync()
在 Crypto.Engine.d__13.MoveNext()

和代码:

    FileOpenPicker fop = new FileOpenPicker();
    fop.FileTypeFilter.Add(".jpg");//extension);
    fop.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
    try
    {
        StorageFile file = await fop.PickSingleFileAsync();
        return file;
    }
        catch(Exception ex) {}

我该如何解决?

4

1 回答 1

0

我遇到了同样的问题并通过将代码放在正确的线程中解决:

CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(
    CoreDispatcherPriority::High,
    ref new DispatchedHandler([]()
{
    // **ATTANTION**: direct call `PickSingleFileAsync` in render loop will crash
    //http://sertacozercan.com/2013/10/fixing-element-not-found-exception-from-hresult-0x80070490-error-in-windows-8-x/
    FileOpenPicker^ openPicker = ref new FileOpenPicker();
    openPicker->ViewMode = PickerViewMode::Thumbnail;
    openPicker->SuggestedStartLocation = PickerLocationId::PicturesLibrary;
    openPicker->FileTypeFilter->Append(".png");
    openPicker->FileTypeFilter->Append(".jpg");
    openPicker->FileTypeFilter->Append(".jpeg");

    auto task = openPicker->PickSingleFileAsync();
}
于 2015-04-10T10:59:57.390 回答