-
[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 ??
-
Re: Reading Text
Better try to use webbrowser control that will help u out to read...
-
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")
-
Re: Reading Text
well Joacim thanks a lot that worked :D 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...
-
Re: Reading Text
If you can view the textfile in your webbrowser you should be able to download it the way I showed.
-
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