0

Hi, I want to know, how I can load all text from some webpage in to my C# aplication RichTextBox?

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by DdoubleD
0

That isn't going to work quite the way you think if you want the formatted text. Websites use a combination of CSS, in-line styling, javascript after the page loads, and probably other means of formatting a site.

Do you want *just* the text or do you want to display the text all pretty and formatted?

0

I need only webpage text. It is like i go to some web page then slect all text (ctrl + a), and copy that text in to notepad. In this case i need that my C# aplication copy that text automatically in to rich textbox.

0

Here is code that will do what you originally asked. Just set your richTextBox1.Text = webHTMLText;, after running it.

string webHTMLText;
            WebClient webClient = new WebClient();

            using (MemoryStream ms = new MemoryStream(webClient.DownloadData("http://daniweb.com/")))
            {
                using (StreamReader sr = new StreamReader(ms))
                {
                    webHTMLText = sr.ReadToEnd();
                    sr.Close();
                }
            }

If there is specific text you want from this before you put it into the control's Text, you would need to know exactly what tags to parse it out of.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.