GetRequestStream()总提示System.NotSupportedException 类型的异常
Streamstream=response.GetResponseStream();stream出错了,错误是Length...
Stream stream = response.GetResponseStream(); stream 出错了,错误是 Length
展开
1个回答
展开全部
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();
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();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询