I want to read in a .txt file from the internet, however my current code for reading in a .txt from a local drive is not compatible with reading in a .txt from a HTTP:// address.
WHat is the correct code?
Thanks!
Printable View
I want to read in a .txt file from the internet, however my current code for reading in a .txt from a local drive is not compatible with reading in a .txt from a HTTP:// address.
WHat is the correct code?
Thanks!
i think you may have your answer on .net forum but i'll post it here just incase
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim w As New Net.WebClient() Dim sr As New IO.StreamReader(w.OpenRead("http://google.com")) Dim strSource As String = sr.ReadToEnd sr.DiscardBufferedData() sr.Close() w.Dispose() TextBox1.AppendText(strSource)'/// assuming you have a textbox there. End Sub
Thanks for this!
How can I add code so that if the page http://www.google.com dose NOT exist (for example) then program dosent crash.
Thanks!