在Windows Phone 8应用程序中下载并解压缩zip文件 [英] download and decompress a zip file in windows phone 8 application
问题描述
我正在使用Windows Phone 8应用程序(phonegap),该应用程序从服务器位置下载一个zip文件,我想在运行时将该文件解压缩到我的应用程序中,以使用存档中的文件.
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.
推荐答案
您可以使用第三方库来解压缩和提取WP7/WP8中的ZIP文件.最常见的是#ZipLib,您可以从@ http://slsharpziplib.codeplex.com/下载WP7端口. a>
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/
我个人最喜欢的库是 DotNetZip ,它是#ZipLib和更稳定的IMO的超集.这是一个快速的代码示例:
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);
}
}
这篇关于在Windows Phone 8应用程序中下载并解压缩zip文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!