download and decompress a zip file in windows phone 8 application

后端 未结 1 1669
-上瘾入骨i
-上瘾入骨i 2021-01-15 00:35

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 th

1条回答
  •  被撕碎了的回忆
    2021-01-15 01:25

    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);
              }
           }
    

    0 讨论(0)
提交回复
热议问题