在做移动端时,当我们需要从服务器获得多个文件时,为了节约流量,服务器一般会返回一个压缩包,那我们就是下载完成后,在手机中进行解压到指定位置

SharpCompress就是可以在手机中进行解压一个类库(.net),在codeplex是开源,支持桌面端和移动端

点击下载最新版本       查看支持内容      API使用示例

下面我们看一下在windows phone中使用其进行解压ZIP包

        public async void DownloadAndUnCompress()
{
string strUrl = "http://qd.baidupcs.com/file/3ebe6e988584733fba61c04e9568bc73?fid=3860865449-250528-923682234289515&time=1401003314&sign=FDTAXER-DCb740ccc5511e5e8fedcff06b081203-sDvdhrr7p1EWhMUFNOaYlQbwLmE%3D&to=qb&fm=Q,B,U,nc&newver=1&expires=1401003914&rt=sh&r=347257022&logid=3996325361&sh=1&vuk=3860865449&fn=SharpCompress0.10.3.zip"; await Task.Run(() =>
{
WebClient wc = new WebClient();
wc.OpenReadAsync(new Uri(strUrl, UriKind.Absolute));
wc.DownloadProgressChanged += (s, dpce) =>
{
System.Diagnostics.Debug.WriteLine("已下载" + dpce.ProgressPercentage + "%");
}; wc.OpenReadCompleted += (s, orce) =>
{
if (orce.Error != null)
{
System.Diagnostics.Debug.WriteLine("下载出错");
return;
} using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
var zipArchive = ArchiveFactory.Open(orce.Result);//创建一个解压器
foreach (var entry in zipArchive.Entries)//提取里面每个实体,包括文件夹都算实体
{
//如果为文件夹先把文件夹创建出来
if (entry.IsDirectory)
{
if (!storage.DirectoryExists(entry.FilePath))
{
storage.CreateDirectory(entry.FilePath);
}
continue;
}
//entry.FilePath 为文件的全路径
using (IsolatedStorageFileStream isofilestream = storage.CreateFile(entry.FilePath))
{
//写入到独立存储空间中
entry.WriteTo(isofilestream);
}
}
zipArchive.Dispose();
System.Diagnostics.Debug.WriteLine("解压完成");
}
};
});
}

其它的如RAR、Tar、GZip、7Zip可参考codeplex官方文档

windows phone使用sharpcompress进行解压压缩文件的更多相关文章

  1. WebApi系列~对HttpClient的响应流进行解压

    回到目录 有时我们的请求头为ContentEncoding添加了gzip进行了压缩,而服务端返回数据时也会对它进行gzip压缩,如果在这种情况下,你直接头响应流会是乱码,而必须先进行压缩,大叔将这块的 ...

  2. 对zip文件进行解压操作和对一个文件进行压缩操作

    注意这里用的是apche下的zip package org.springframework.validation; import org.apache.tools.zip.ZipEntry; impo ...

  3. linux解压/压缩文件

    1.*.tar 用 tar –xvf 解压  2.*.gz 用 gzip -d或者gunzip 解压  3.*.tar.gz和*.tgz 用 tar –xzf 解压  4.*.bz2 用 bzip2 ...

  4. Qt 解压/压缩文件

    很久没有在博客园写随笔了,今天项目需要解压和压缩文件,所以去了解哈. 参考的是大神的代码:https://yq.aliyun.com/articles/24428. 使用的是 QuaZIP类. 类 说 ...

  5. c# 用DotNetZip来解压/压缩文件

    //https://archive.codeplex.com/?p=dotnetzip //最新在Nuget 下载DotNetZip using Ionic.Zip; private void but ...

  6. Ubuntu下解压压缩文件

    1.ZIP解压    ZIP因为它的跨平台使用优点,是目前使用率最高的一种压缩方式,但是它的压缩率相比较tar.gz和tar.gz2来讲,却要低很多.    压缩命令:zip -r archive_n ...

  7. Linux 解压 压缩文件

    来源于:http://blog.csdn.net/mmllkkjj/article/details/6768294/ 解压 tar –xvf file.tar //解压 tar包tar -xzvf f ...

  8. 解压压缩文件报错gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now

    压缩包是直接weget 后面加官网上的tar包地址获取的  [root@xuegod43 ~]# tar -zxvf /home/hadoop/hadoop-2.6.5-src.tar.gz gzip ...

  9. Bug :”解压压缩文件失败: cpio; 在头中不存在归档“

    问题描述: 在rpm包目录下执行rpm -ivh *rpm -force时,出现标题错误 解决办法: *src.rpm包也就源码包不能被直接进行安装,需要先将src.rpm包进行编译生成二进制的rpm ...

随机推荐

  1. a trick in reading and storing file in the exact way!

    read and write file is a very common operation regarding file mainuplation. However, the powerfull g ...

  2. Pearls DP

    Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6647   Accepted: 3241 Description In Pe ...

  3. 学习Javascript闭包(Closure) by 阮一峰

    闭包(closure)是Javascript语言的一个难点,也是它的特色,很多高级应用都要依靠闭包实现. 一.变量的作用域 要理解闭包,首先必须理解Javascript特殊的变量作用域. 变量的作用域 ...

  4. baidu面试题

    百度:http://blog.chinaunix.net/uid-26602509-id-3306451.html http://lvwenwen.iteye.com/blog/1504379

  5. 使用 virtualenv

    关于virtualenv的资料: http://virtualenv-chinese-docs.readthedocs.org/en/latest/ 用的python3,但是搭建 Robot Fram ...

  6. 解码美国传奇网络券商:TradeStation

    证券时报记者 桂衍民 张欣然 5万客户,交易量却占美国网络券商8%,网络影响力已连续两年被评为全美前五名,说起美国网络证券,必提TradeStation. TradeStation的确是美国证券界的一 ...

  7. sqlserver客户端连接只显示特定数据库的配置方法

    首先,在实例级,有一个 view any database的这个属性,打开时可以看到所有数据库的元数据表,因此能看到实例下所有数据库的名字.默认public角色拥有这个属性.所以新建的登陆是可以看到所 ...

  8. Git git rebase 使用

      原文:http://gitbook.liuhui998.com/4_2.html 一.基本 git rebase用于把一个分支的修改合并到当前分支. 假设你现在基于远程分支"origin ...

  9. boost库在工作(32)网络服务端之二

    在这个例子里,服务器对象主要使用boost::asio::io_service对象,这个对象主要用来构造异步接收数据使用,接着定义boost::asio::ip::tcp::acceptor对象,这个 ...

  10. RHEL6.4编译安装gcc4.8.1

    因为平时用的linux虚拟机都是RHEL6.4, 自带的gcc版本号太低,不支持C++11,而从gcc4.8.1開始, gcc完美支持C++11全部特性. 故升级了一下. 以下是具体步骤: 1. 下载 ...