c# – UWP app:FileOpenPicker PickSingleFileAsync()无法等待
作者:互联网
我试图让用户使用FileOpenPicker类浏览文件,但是当我使用PickSingleFileAsync函数等待时,我收到以下错误:
‘IAsyncOperation’ does not contain a definition for ‘GetAwaiter’ and no extension method ‘GetAwaiter’ accepting a first argument of type ‘IAsyncOperation’ could be found (are you missing a using directive for ‘System’?)
这是在最后一行给出错误的函数:
private async void browseFileButton_Click(object sender, RoutedEventArgs e) {
FileOpenPicker filePicker = new FileOpenPicker();
filePicker.ViewMode = PickerViewMode.Thumbnail;
selectedFile = await filePicker.PickSingleFileAsync();
}
Microsoft提供的文档包含一个以相同方式使用FileOpenPicker的示例.有没有人遇到这个问题或有任何人解决这个问题?
解决方法:
你有没有:
使用系统;
在类文件的顶部?我刚刚尝试将您的示例添加到项目中并在删除此引用时复制了您的错误…
标签:c,windows,async-await,uwp,filepicker 来源: https://codeday.me/bug/20190717/1489018.html