Windows 8.1 FileOpenPicker

时间:2014-09-19 20:36:50

标签: windows-8 windows-8.1 fileopenpicker

我为windows商店制作了应用程序。它运行正常,直到我将我的操作系统升级到Windows 8.1。我在尝试使用FileOpenPicker时出错:

  

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

这是stacktrace:

  

在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) {}

我该如何解决?

1 个答案:

答案 0 :(得分: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();
}