Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing application which am showing web pages through web browser control. While am clicking save button,the web page with images should be store in local storage. it should be save in .html format.
please any one explain how to do and give solution.

here is my code

WebRequest request = WebRequest.Create(txtURL.Text);
WebResponse response = request.GetResponse();
Stream data = response.GetResponseStream();
string page = String.Empty;
using (StreamReader sr = new StreamReader(data))
{
page = sr.ReadToEnd();
}
Thanks in Advance..
Posted
Updated 15-May-15 20:40pm
v3

1 solution

Write this under save button click event,

C#
File.WriteAllText(path, browser.Document.Body.Parent.OuterHtml, Encoding.GetEncoding(browser.Document.Encoding));


Body.parent will save whole the page instead of saving only part....

that's it,
 
Share this answer
 
Comments
Eliz Deena 16-May-15 2:39am    
Hi Tiririk,
where it will store.. i want to store it on D:\\Cache\\
Please explain more..

here is my code

WebRequest request = WebRequest.Create(txtURL.Text);
WebResponse response = request.GetResponse();
Stream data = response.GetResponseStream();
string page = String.Empty;
using (StreamReader sr = new StreamReader(data))
{
page = sr.ReadToEnd();
}

now page have the full content.. how to store it into this path D:\\Cache

Please help me..
Tiririk 16-May-15 2:56am    
just change path with your "path"....
Eliz Deena 16-May-15 3:12am    
I could not get Tiririk..

File.WriteAllText("D:\\Cache\\", webBrowser1.Document.Body.Parent.OuterHtml, Encoding.GetEncoding(webBrowser1.Document.Encoding));

i gave like above.. its telling Could not find a part of the path 'D:\Cache\'.

how to do further..

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