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

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. 【HDOJ】2896 病毒侵袭

    AC自动机模板题. #include <iostream> #include <cstdio> #include <cstring> #include <qu ...

  2. 【HDOJ】2268 How To Use The Car

    数学题.设步行速度a,车速b,距离c.Teddy步行时间为T1,WhereIsHeroFrom步行时间T2,总时间T.若b>a:aT1 + b(T-T1) = c (1)aT2 + b(T-T2 ...

  3. LVS+Keepalived+Nginx+Tomcat高可用负载均衡集群配置(DR模式,一个VIP,多个端口)

    一.概述 LVS作用:实现负载均衡 Keepalived作用:监控集群系统中各个服务节点的状态,HA cluster. 配置LVS有两种方式: 1. 通过ipvsadm命令行方式配置 2. 通过Red ...

  4. MVVM模式中WPF数据的完全绑定

    一:截图,描述:将后台代码的姓名.年龄绑定到文本框,单击”增加年龄“--年龄自+1,单击”显示年龄“--弹出年龄的显示对话框,实现了从文本框修改年龄和后台更改年龄并显示到文本框 运行结果和解决方案管理 ...

  5. Divide Two Integers —— LeetCode

    Divide two integers without using multiplication, division and mod operator. If it is overflow, retu ...

  6. 接口中的成员变量必须是static

    首先要弄清接口的含义. 接口就是提供一种统一的'协议’, 而接口中的属性也属于'协议’中的成员.它们是公共的,静态的,最终的常量.相当于全局常量. 在interface里面的变量都是public st ...

  7. errno与perror

    很多系统函数在错误返回时将错误原因记录在libc定义的全局变量errno中,每种错误原因对应一个错误码,请查阅errno(3)的Man Page了解各种错误码,errno在头文件errno.h中声明, ...

  8. kafka单机安装配置

    1.下载kafka wget https://www.apache.org/dyn/closer.cgi?path=/kafka/0.8.2.1/kafka_2.9.2-0.8.2.1.tgz 2.解 ...

  9. 【转载】运维小技巧:使用ss命令代替 netstat

    转自:https://www.91ri.org/12470.html ss是Socket Statistics的缩写. 顾名思义,ss命令可以用来获取socket统计信息,它可以显示和netstat类 ...

  10. openresty nginx 安装过程记录

    转载请注明原始地址 http://www.cnblogs.com/dongxiao-yang/p/4877799.html 一 :系统版本 1 cat /etc/issue: CentOS relea ...