/// <summary> /// 读取为二进制数组并转换为指定的编码 /// </summary> /// <param name="httpContent"></param> /// <param name="dstEncoding">目标编码</param> /// <exception cref="ArgumentException"></exception> /// <returns></returns> public static async Task <byte[]> ReadAsByteArrayAsync(this HttpContent httpContent, Encoding dstEncoding) { var encoding = httpContent.GetEncoding(); var byteArray = await httpContent.ReadAsByteArrayAsync().ConfigureAwait(false); return(encoding.Equals(dstEncoding) ? byteArray : Encoding.Convert(encoding, dstEncoding, byteArray)); }