开发者

Zip library for Windows Phone 7

开发者 https://www.devze.com 2023-01-21 07:51 出处:网络
I\'m downloading zip files and place them in isolated storage on Windows Phone 7. Is the开发者_StackOverflowre an API or library that allows me to unzip the files?You can use SharpZipLib to decompress

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


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


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消