原始 Restsharp 不支持 UWP,我使用 FubarCoder.Restsharp.Portable 包。 我用
var request = new RestRequest(host, Method.GET);
var response = await client.Execute<HttpWebResponse>(request);
和response.RawBytes
是原始字节数组。我如何从中提取数据?我的回复包含 epub 文件,我需要将其保存到文件中。
最佳答案
首先,您需要您要写入的文件的路径,请注意,您不能简单地写入 UWP 中的任何路径。您可以在 MSDN 上找到所有可访问位置的列表。 .
然后简单地使用 File.WriteAllBytes 方法将字节数组转储到文件中。
IRestResponse response = await client.Execute(request);
byte[] bytes = response.RawBytes;
File.WriteAllBytes(yourFile.Path, bytes);
关于c# - 如何从 Fubarcoder Restsharp 客户端提取内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38875656/