I am using the following code to read and save to file the html code of a web page and this works. When I replacewithCode:FileWriter.WriteLine(MyStream.ReadToEnd)
so that I can save the stream line by line it only saves the entire html page about half of the time. The other half it saves about 50% of the html code only. Anyone know why?Code:While MyStream.Peek <> -1 FileWriter.WriteLine(MyStream.ReadLine()) End While
Code:Dim MyRequest As System.Net.HttpWebRequest Dim MyResponse As System.Net.HttpWebResponse Dim MyStream As System.IO.StreamReader Dim FileWriter As IO.StreamWriter MyRequest = System.Net.WebRequest.Create("http://www.domain.com") MyResponse = MyRequest.GetResponse() MyStream = New System.IO.StreamReader(MyResponse.GetResponseStream()) FileWriter = New IO.StreamWriter("html.txt") FileWriter.WriteLine(MyStream.ReadToEnd) FileWriter.Flush() FileWriter.Close() MyStream.Close() MyResponse.Close()


Reply With Quote