0

Hello All
Im trying to get html saved to a text file after the Url has been entered into a text box Im having difficulties with this can anyone help. I have no problem saving text to a text file and reading text from a file.

Thankis

2
Contributors
3
Replies
5
Views
10 Years
Discussion Span
Last Post by sedgey
0

have you tried using the WebClient class to stream the html from the URL?

I am not a VB guy but in C# looks like this:

System.Net.WebClient client = null;
try
{
client = new System.Net.WebClient();
client.Encoding = Encoding.UTF8;
client.Headers = new System.Net.WebHeaderCollection();
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2;)");
string html = client.DownloadString(txtDomain.Text + url);
AddPageToDB(txtDomain.Text + url, html);
}
catch {//error handling code here}
finally
{
client.Dispose();
}
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.