download and decompress a zip file in windows phone 8 application

偶尔善良 提交于 2019-12-01 09:15:23

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/14852710/download-and-decompress-a-zip-file-in-windows-phone-8-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!