Results 1 to 3 of 3

Thread: Read a .txt from HTTP

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    6

    Read a .txt from HTTP

    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!

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    i think you may have your answer on .net forum but i'll post it here just incase
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim w As New Net.WebClient()
    3.         Dim sr As New IO.StreamReader(w.OpenRead("http://google.com"))
    4.         Dim strSource As String = sr.ReadToEnd
    5.         sr.DiscardBufferedData()
    6.         sr.Close()
    7.         w.Dispose()
    8.         TextBox1.AppendText(strSource)'/// assuming you have a textbox there.
    9.     End Sub
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    6
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width