C# windows.web.http和ByteArray
我在Windows Phone 8.1应用程序中使用了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发送和获取文件 正确的方法
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();