适用于 Windows Phone 7 的 Zip 库 [英] Zip library for Windows Phone 7

查看:26
本文介绍了适用于 Windows Phone 7 的 Zip 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在下载 zip 文件并将它们放在 Windows Phone 7 上的独立存储中.是否有允许我解压缩文件的 API 或库?

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?

推荐答案

您可以使用 SharpZipLib 解压缩下载的 zip 文件.我在我的应用程序中使用了这个版本(从 Codeplex 下载的二进制文件),没有任何问题,但是,我建议下载源代码并自己编译.解压后的文件可以读入字符串 -

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 是一个字节数组,用于保存从 IndependentStorage 读取的 zip 文件.fileContents 是一个保存解压文件内容的字符串.

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

HTH, indyfromoz

这篇关于适用于 Windows Phone 7 的 Zip 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆