C# windows.web.http和ByteArray

C# windows.web.http和ByteArray,c#,web-services,bytearray,windows-phone-8.1,dotnet-httpclient,C#,Web Services,Bytearray,Windows Phone 8.1,Dotnet Httpclient,我在Windows Phone 8.1应用程序中使用了System.net.http,直到我的自签名和不可信证书出现问题 现在,我使用的是Windows.Web.Http框架。除了在IHttpContent界面中找不到与ByteArrayContent等价的内容外,一切都很正常。同样地,IHttpContent没有与ReadAsByteArrayAsync等效的方法 我使用ByteArrayContent和ReadAsByteArrayAsync通过HttpClient发送和获取文件 正确的方法

我在Windows Phone 8.1应用程序中使用了
System.net.http
,直到我的自签名和不可信证书出现问题

现在,我使用的是
Windows.Web.Http
框架。除了在
IHttpContent
界面中找不到与
ByteArrayContent
等价的内容外,一切都很正常。同样地,
IHttpContent
没有与
ReadAsByteArrayAsync
等效的方法

我使用
ByteArrayContent
ReadAsByteArrayAsync
通过HttpClient发送和获取文件

正确的方法是什么


谢谢

使用
HttpBufferContent
IHttpContent.ReadAsBufferAsync()

通过WinRT扩展,您可以调用
myArray.AsBuffer()
,将数组转换为
IBuffer

// using System.Runtime.InteropServices.WindowsRuntime;
byte[] foo = new byte[] { 20, 21, 22, 23 };
IHttpContent content = new HttpBufferContent(foo.AsBuffer());

// using Windows.Storage.Streams;
IBuffer barBuffer = await content.ReadAsBufferAsync();
byte[] bararray = barBuffer.ToArray();