sma6871
sma6871

Reputation: 3298

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.

Upvotes: 0

Views: 1083

Answers (1)

Adam
Adam

Reputation: 15803

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.

Upvotes: 1

Related Questions