Hello,
No WebBrowser can't download file but here are two classes that can do it :
You can use WebClient or HttpWebRequest
WebClient
Code:
WebClient client = new WebClient();
client.OpenReadCompleted += new OpenReadCompletedEventHandler(YourMethodToGetTheFile_OpenReadCompleted);
client.OpenReadAsync(new Uri("http://www.WebSite.com/TheFile.ppt"));
HttpWebRequest
Code:
var uri = new Uri("http://www.WebSite.com/TheFile.ppt");
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
request.BeginGetResponse(new AsyncCallback(YourMethodToGetTheFile_AsyncCallBack), request);
You can use one of the snippets above and then simply store the stream you get as a response in the IsolatedStorageFile
something like this for the WebClient
Code:
void YourMethodToGetTheFile_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
var storeFile = IsolatedStorageFile.GetUserStoreForApplication();
using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream("TheFile.ppt", System.IO.FileMode.Create, storeFile ))
{
byte[] buffer = new byte[1024];
while (e.Result.Read(buffer, 0, buffer.Length) > 0)
{
stream.Write(buffer, 0, buffer.Length);
}
}
}
Don't forget to delete the file if exist in the IsolatedStorage, I didn't handle it in the example.