【问题标题】:How to download audio files (wav or mp3) from HttpResponseMessage Steam Content response in c#?如何从 c# 中的 HttpResponseMessage Steam 内容响应下载音频文件(wav 或 mp3)?
【发布时间】:2019-03-11 22:37:36
【问题描述】:

我的代码如下:

URL = "https://abcde.com/api//export/1234.wav?type=wav";
HttpResponseMessage response = client.GetAsync(URL).Result;

显示的是"StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent"

StreamContent是一个wav文件,文件名为1234.wav。 如何在 C# 中从HttpResponseMessage Steam Content response 下载 wav 文件?

非常感谢。

【问题讨论】:

  • 使用“HttpClient 客户端”,而不使用“等待”

标签: c# httpresponsemessage


【解决方案1】:

在您的 HttpResponse 对象中会有一个响应字段。你有几个选择。你想做的是使用ReadAsStreamAsync().Result;

这将在您的 HttpResponse 消息中输出内容流。

阅读更多关于httpcontent here

【讨论】:

  • 谢谢,但是你能告诉我如何使用流来下载文件吗?还是我不需要?
  • 所以,这里不是 wav 文件的专家。但是,如果您查看here,他们使用内存流来使用 wav 文件。所以如果你有它在流文件中,它只是我们如何特别使用我们的字节的一个过程
猜你喜欢
  • 2014-05-31
  • 2019-01-07
  • 1970-01-01
  • 1970-01-01
  • 2011-09-11
  • 1970-01-01
  • 1970-01-01
  • 2023-03-23
  • 1970-01-01
相关资源
最近更新 更多