Results 1 to 6 of 6

Thread: [RESOLVED] Reading Text

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    62

    Resolved [RESOLVED] Reading Text

    Hi, I am making an application and I need to read text with to be more specific
    I want to make my application read txt files but that are in web (e.g www.somesite.com/myfile.txt)
    grab the text from that file and load it in a Richbox
    here is what Ive done until now...

    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    RichTextBox1.LoadFile("http://mysite.com/sometext.txt", RichTextBoxStreamType.PlainText)         
    If RichTextBox1.Text = "" Then
    MsgBox("The text has been loaded")
    End If     
    End Sub
    But with this code I got an error : "URI formats are not supported."
    So as far as I understand Richbox can't read web files directly without maybe downloading them in local PC then reading.
    But I don't want the download method...
    So is there any method that can read web text files DIRECTLY ??

  2. #2
    Addicted Member
    Join Date
    Feb 2008
    Location
    XP & Vista
    Posts
    181

    Re: Reading Text

    Better try to use webbrowser control that will help u out to read...
    _____________________________________________
    Regrads,
    kpmsivachand

    Don't walk in front of me, I may not follow; Don't walk behind me, I may not lead;
    Walk beside me, and just be my friend.

    Need Reviews: 1. PDF Split, PDF Merge, PDF Encrypt, PDF Decrypt and PDF Watermark

    Need Reviews: 2. Folder Locker | Lock Folder | File Locker | Locker | Encrryption | Encrypt

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Reading Text

    Well, if you want to read a remote file on your computer you have to download it first there's no way to avoid that. However that doesn't mean you have to store the file on your local computer, you can just download the text into a string.
    Code:
        Dim webClient As New System.Net.WebClient
        RichTextBox1.Text = webClient.DownloadString("http://www.server.com/file.txt")

  4. #4

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    62

    Re: Reading Text

    well Joacim thanks a lot that worked but I have a free host and it does not allow me to read the file as a string, I got error 403
    anyway thanks again...
    I know maybe I'm being very annoying now but is maybe there another reading method
    I can't afford to pay for web hosting just to allow me to do this...

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Reading Text

    If you can view the textfile in your webbrowser you should be able to download it the way I showed.

  6. #6

    Thread Starter
    Member
    Join Date
    Sep 2007
    Posts
    62

    Re: Reading Text

    yes I can view it through the web but i couldn't with my program
    but anyway I fixed this since I changed the web hosting with another free host but that was allowing me to do this..
    so thanks again
    Best Regards
    Last edited by jareck; May 27th, 2021 at 02:01 PM. Reason: removing personal info

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