简体   繁体   中英

How to save WebBrowser page in wp7?

I have WebBrowser control in my WP7 app

I want to save the page in HTML or PDF or JPG file in isolated memory for read it later.

you can use a WebClient :

WebClient downloader = new WebClient();
downloader.DownloadStringCompleted += (o, e) => DoSomethingWithResult(e.Result);
downloader.DownloadStringAsync(new Uri(yourWebBrowser.Source.ToString()));

private void DoSomethingWithResult(string result)
{
    //...
}

Of course, you need to check e.Error and so on... I left that out for the sake of brevity.

In order to download the entire page , not just the HTML, you should look into this question . Be warned, it probably isn't as simple as you think.

EDIT: in order to show the HTML you saved using the above method, call WebBrowser.NavigateToString(result) .
You can find an example in this blog post .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM