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

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();
}

Thanks for your help
Im not that uste of c# though

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.