I have a fairly complex scenario that I try to port to Windows 8 from Windows Phone 7.
I need to
- Download s Zip file from the internet
- Unzip it to the isolated storage
- Read the unzipped xml files and images
Problems
-
In Windows Phone 7 I use WebClient that is no longer available in Windows 8. I tried HttpClientHandler but I am only able to download the ZIP file as a string and I do no know how to save it to isolated storage.
-
I found ZipArchive class but it takes a IO.Stream and I am not really sure how to use it (if I had the file save somewehre – point 1)
I’m just starting out with the new API’s as well (so this might be off a bit), but based on the documentation:
HttpClient(and it’s default handlerHttpClientHandler) return aTask<HttpResponseMessage>fromSendAsync.HttpResponseMessagehas a property,Contentwhich is of typeHttpContent.HttpContentin turn has a method,ReadAsStreamAsync, which returnsTask<Stream>which you should be able to use (albeit indirectly) to pass toZipArchive.Or you can just use the
HttpClient.GetStreamAsyncmethod to get the stream (much simpler):If that doesn’t work then you could also just wrap the string you get now in aMemoryStreamand pass it toZipArchivebut that sounds kind of unsafe because of possible encoding problems.