2

I am working on a windows phone 8 application (phonegap) which downloads a zip file from my server location, I want to unzip this file in my application at runtime to use the files in the archive.

Ankita Rajain
  • 53
  • 1
  • 5

1 Answers1

2

You can use 3rd party libraries in order to decompress and extract ZIP files in WP7/WP8. The most common one is #ZipLib which you can download the WP7 port from @ http://slsharpziplib.codeplex.com/

My personal favourite library is DotNetZip which is a superset of #ZipLib and much more stable IMO. Here's a quick code sample:

  private void MyExtract()
  {
      string zipToUnpack = "C1P3SML.zip";
      string unpackDirectory = "Extracted Files";
      using (ZipFile zip1 = ZipFile.Read(zipToUnpack))
      {
          // here, we extract every entry, but we could extract conditionally
          // based on entry name, size, date, checkbox status, etc.  
          foreach (ZipEntry e in zip1)
          {
            e.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently);
          }
       }
JustinAngel
  • 16,082
  • 3
  • 44
  • 73