|
-
Feb 8th, 2010, 10:41 AM
#1
Thread Starter
Member
[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 ??
-
Feb 8th, 2010, 10:48 AM
#2
Addicted Member
Re: Reading Text
Better try to use webbrowser control that will help u out to read...
-
Feb 8th, 2010, 10:50 AM
#3
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")
-
Feb 8th, 2010, 11:02 AM
#4
Thread Starter
Member
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...
-
Feb 8th, 2010, 11:25 AM
#5
Re: Reading Text
If you can view the textfile in your webbrowser you should be able to download it the way I showed.
-
Feb 9th, 2010, 09:53 AM
#6
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|