I'm using below code to get the first Length bytes of the web page. Now, I want to skip the first 50K bytes, and get the following 50K bytes. Is there a way to do that? Or I have to read the first 100K bytes? The first 50K bytes are useless to me and it slows down the program.
thank you very much.
VB Code:
Try Dim webReq As HttpWebRequest = DirectCast( _ WebRequest.Create(strURL), HttpWebRequest) ' Set a 30-second timeout. webReq.Timeout = 30000 ' 30 seconds webReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" webReq.KeepAlive = False ' turn off persistent connections webReq.Accept = "text/html, text/xml" webReq.ReadWriteTimeout = 30000 Dim webResp As HttpWebResponse = DirectCast( _ webReq.GetResponse, HttpWebResponse) Dim sr As New StreamReader(webResp.GetResponseStream, Encoding.ASCII) Dim lngLength As Long = Length Dim chrBlock() As Char ReDim chrBlock(lngLength * 1024) sr.ReadBlock(chrBlock, 0, lngLength * 1024) html = CType(chrBlock, String).Trim ' always close sr.Close() sr = Nothing Catch ex As WebException html = "" End Try





Reply With Quote