Zip library for Windows Phone 7

你离开我真会死。 提交于 2020-01-03 02:27:13

问题


I'm downloading zip files and place them in isolated storage on Windows Phone 7. Is there an API or library that allows me to unzip the files?


回答1:


You can use SharpZipLib to decompress downloaded zip files. I have used this version (binaries downloaded from Codeplex) in my applications without any issues, however, I would recommend download the source and compiling it yourself. The decompressed file can be read into a string -

// check for magic numbers
if (data.Length > 2 && (data[0] == 31 && data[1] == 139))
{
   using (var ms = new MemoryStream(data))
   using (var gzip = new GZipInputStream(ms))
   using (var reader = new StreamReader(gzip))
   {
      fileContents = reader.ReadToEnd();
   }
}         

data is an array of bytes which holds the zip file read from IsolatedStorage. fileContents is a string that holds the contents of the decompressed file.

HTH, indyfromoz




回答2:


SharpZipLib is under GNU license and is therefore not allowed by the Microsoft app store.




回答3:


I found the following small library useful for unzipping files on WP7:
REALLY small unzip utility for Silverlight – Part 2



来源:https://stackoverflow.com/questions/4007758/zip-library-for-windows-phone-7

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