按照标题。我点击我的按钮,并且可以在调用openPicker.PickSingleFileAsync()
的线上的断点处输入调试器 - 但这个调用永远不会返回。我可以选择一个文件,然后单击“打开”,但我从来没有回到我的方法来实际上对该文件执行某些操作。这是全新的Windows Metro空白应用程序,只有一个按钮和一个图像。FileOpenPicker.PickSingleFileAsync永不返回
private void Button_Click_1(object sender, RoutedEventArgs e)
{
OpenFile().Wait();
}
private async Task OpenFile()
{
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
// can break on following line
var file = await openPicker.PickSingleFileAsync();
// this line is never reached
if (file != null)
{
// do stuff
}
}
这是按照示例代码on MSDN here。当我使用PickMultipleFilesAsync时也会得到相同的结果。
我错过了一些明显的东西吗?