How can i download a zipped folder from a remote server and unzip the entire files in the folder and store them in isolated storage space from a silver light 3 or 4 out of browser application. Any suggestion please
-
Can use the Elevated priviledges of Silverlight 4? Minimum Windows version you wish to support? – AnthonyWJones Jan 25 '10 at 12:57
4 Answers
You can download a zip file like any files with the Webclient class, look at the details and examples in the msdn documentation for downloading content on demand it even talks about how to download and get a specific file from a zip archive.
However if you want to list the files, check out this blogpost, I've not actually tried it but it shows how to get all the files in a zip archive.
Edit: I also found this discussion which offers some ideas, it among other things mentions this Small unzip utility for Silverlight, which seems a bit more robust.
Then use the IsolatedStorageFile class to save the files.
Good Luck! Ola

- 9,011
- 7
- 27
- 37
-
The blog post assumes the entry names are encoded in UTF-8, unfortunately many Zip files will use IBM437 for the character encoding and the zip format doesn't provide a means to determine which encoding was used. – AnthonyWJones Jan 25 '10 at 12:54
-
Good point, the second utility I found, the "Small unzip utility" might be a bit more robust, but then it might have the same flaw, I'm not familiar with zip encoding etc... – Ola Karlsson Jan 25 '10 at 13:07
-
Unfortunately the link to the "Small unzip utititly" is broken as of today...See http://www.sharpgis.net/post/2009/04/22/REALLY-small-unzip-utility-for-Silverlight.aspx – Marcel Sep 07 '10 at 21:12
For the (un)zipping I'd highly recommend that you use the open source DotNetZip library. DotNetZip is licensed under the Ms-PL and really easy to use.
Zipping for example is easy too:
using (ZipFile zip = new ZipFile())
{
zip.AddEntry("MyFileName.png", null, pngStream);
// Save to stream from SaveFileDialog
zip.Save(stream);
}

- 2,962
- 1
- 19
- 26
Silverlight SharpZipLib is a full Silverlight 3/4 and Phone7 port, less AES encryption, of SharpZipLib.
The salient limitation is one that you will find in all Silverlight compression: Only UTF8 encoding of entry meta is supported.

- 36,396
- 8
- 69
- 90
you could get the file using http or frp stream and then use GZipStream (.NET Class) for unziping the stream/file.
GzipStream: http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream.aspx
Cheers --Jocke

- 2,189
- 1
- 16
- 24