| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 711 人关注过本帖
标题:想下载文件的部分字节,为什么request.AddRange()不起作用?
只看楼主 加入收藏
whwclp
Rank: 1
等 级:新手上路
威 望:1
帖 子:3
专家分:0
注 册:2014-3-6
收藏
 问题点数:0 回复次数:1 
想下载文件的部分字节,为什么request.AddRange()不起作用?
我想从文件中读取一部分字节,可是不知为什么总是读取了整个文件,请各位赐教:
 原文件大小:3452字节
 程序如下:
 
         Dim totalBytes As Integer = 0
         Dim fs1 As New FileStream(Path.GetFileNameWithoutExtension("test") + ".$$", FileMode.Create)
         Try
             Dim rqs As HttpWebRequest
             rqs = CType(HttpWebRequest.Create("http://.../templates/jtjy/skins/default/images/jy_01.gif"), HttpWebRequest)
             rqs.AddRange(0, 2452)
             Dim strm As Stream
             strm = rqs.GetResponse.GetResponseStream
             Dim receiveBytes(512 - 1) As Byte
             Dim readBytes As Integer
             readBytes = strm.Read(receiveBytes, 0, receiveBytes.Length)
             Do While readBytes > 0
                 fs1.Write(receiveBytes, 0, readBytes)
                 totalBytes += readBytes
                 readBytes = strm.Read(receiveBytes, 0, receiveBytes.Length)
             Loop
             strm.Close()
         Catch ex As Exception
             MsgBox(ex.Message)
         End Try
搜索更多相关主题的帖子: default 下载文件 images 
2014-03-06 08:46
whwclp
Rank: 1
等 级:新手上路
威 望:1
帖 子:3
专家分:0
注 册:2014-3-6
收藏
得分:0 
没人知道吗?别让人失望啊!
2014-03-06 10:25
快速回复:想下载文件的部分字节,为什么request.AddRange()不起作用?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019311 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved