How can I download and save a file to IsolatedStorage
asynchronously?
I used WebClient
first for the purpose, but I couldn\'t await till completion
In my opinion best way to use native implementation like this (Wrapping Begin/End asynchronous API):
var url = new Uri(UriString, UriKind.Absolute);
var fileName = Path.GetFileName(url.LocalPath);
var w = WebRequest.CreateHttp(url);
var response = await Task.Factory.FromAsync(w.BeginGetResponse, w.EndGetResponse, null);
await response.GetResponseStream().CopyToAsync(new FileStream(ApplicationData.Current.LocalFolder.Path + @"\" + fileName, FileMode.CreateNew));