Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to read the content in html file online and save all the content text in .txt document. Can anyone tell me how to read the text from html document?
Posted
Comments
Richard C Bishop 21-Dec-12 10:14am    
A simple google search found this:

http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/060ea8e0-cc63-44a3-b0dc-b531c29b8a0f/
.Net_Vivek 24-Dec-12 2:16am    
Thank you for the link, I have searched a lot before but didn't get the required answer, Thanx a lot!
BillWoodruff 22-Dec-12 9:54am    
What have you tried so far ?

1 solution

If you mean download the source of a webpage...

C#
using System;
using System.IO;
using System.Net;


And the function...

C#
public static void SaveSource(string url, string path)
{
    WebClient client = new WebClient();
    string source = client.DownloadString(url);
    File.WriteAllText(path, source);
}


For faster results of getting the source of a webpage, you may want to look into HttpWebRequests.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900