如何取到http流的长度?

DataBind 2005-02-06 10:31:52
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);

httpWebRequest.KeepAlive = false;

HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();

Stream streamResponse=httpWebResponse.GetResponseStream();
BinaryReader binaryReader = new BinaryReader(streamResponse);

buffer = new byte[streamResponse.Length];

最后一行代码有问题!我该怎么取呢?我要建立一个缓冲区,byte[]类型的。
...全文
74 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
DataBind 2005-02-06
  • 打赏
  • 举报
回复
httpWebResponse.ContentLength
happyfish21cn 2005-02-06
  • 打赏
  • 举报
回复
nod
wj2929 2005-02-06
  • 打赏
  • 举报
回复
通过
long l=Convert.ToInt32(httpWebResponse.Headers["Content-Length"].ToString());
获得

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧