Monday 15 March 2010

windows phone 8 - Download and save an HttpRequestMessage C# -



windows phone 8 - Download and save an HttpRequestMessage C# -

in wp8.1 silverlight app, want download file , save isolated storage. downloading ok, how can save ?

for downloading, utilize :

var httpclientdownloadfile = new windows.web.http.httpclient(); windows.web.http.httprequestmessage request = new windows.web.http.httprequestmessage(windows.web.http.httpmethod.get, new uri(downloadurl)); request.headers.add("range", "bytes=0-"); // hook progress handler. progress<httpprogress> progresscallback = new progress<httpprogress>(onsendrequestprogress); var tokensource = new cancellationtokensource(); windows.web.http.httpresponsemessage response = await httpclientdownloadfile.sendrequestasync(request).astask(tokensource.token, progresscallback);

if run debug, in response.content have download. now, want save isolated storage. how can ? should utilize stream ?

thanks

convert response stream , write file

using (var filestream = await this.storagefile.openfileasync(filename, filemode.openorcreate)) { await stream.copytoasync(filestream); }

c# windows-phone-8

No comments:

Post a Comment