GetResponseStream 的流不支持 Length
7/19/2016 12:34:00 AM
GetResponseStream 的流不支持 Length
Stream responseStream = httpWebResponse.GetResponseStream();
BinaryReader binaryReader = new BinaryReader(responseStream);
byte[] arraryByte = new byte[responseStream.Length];
binaryReader.Read(arraryByte, 0, (int)responseStream.Length);
改为
MemoryStream stmMemory = new MemoryStream();
byte[] buffer = new byte[64 * 1024];
int i;
while ((i = responseStream.Read(buffer, 0, buffer.Length)) > 0)
{
stmMemory.Write(buffer, 0, i);
}
byte[] arraryByte = stmMemory.ToArray();
stmMemory.Close();