且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Windows /控制台应用程序中从WEB API响应获取流数据

更新时间:2023-02-15 07:49:12

我建议您使用的 async-await 关键字,您可以像这样更改代码以获取结果:

what I would suggest to you is using the async-await keywords here, you can change your code like this to get the results:

HttpResponseMessage file = await httpclinet.GetAsync("url");
var stream = await file.Content.ReadAsStreamAsync()

此外,您还需要添加 async 关键字,例如:

Also you need to add the async keyword to your method like this:

public async Task<HttpResponseMessage> download(string fileid)