views:

189

answers:

4

Hi All,

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

A: 

Hi, 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

Jocke
System.IO.Compression not present in Silverlight
AnthonyWJones
+5  A: 

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

Ola Karlsson
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
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
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
A: 

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);
 } 
Rene Schulte
A: 

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.

Sky Sanders