windows phone使用sharpcompress进行解压压缩文件
在做移动端时,当我们需要从服务器获得多个文件时,为了节约流量,服务器一般会返回一个压缩包,那我们就是下载完成后,在手机中进行解压到指定位置
SharpCompress就是可以在手机中进行解压一个类库(.net),在codeplex是开源,支持桌面端和移动端
下面我们看一下在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进行解压压缩文件的更多相关文章
- WebApi系列~对HttpClient的响应流进行解压
回到目录 有时我们的请求头为ContentEncoding添加了gzip进行了压缩,而服务端返回数据时也会对它进行gzip压缩,如果在这种情况下,你直接头响应流会是乱码,而必须先进行压缩,大叔将这块的 ...
- 对zip文件进行解压操作和对一个文件进行压缩操作
注意这里用的是apche下的zip package org.springframework.validation; import org.apache.tools.zip.ZipEntry; impo ...
- linux解压/压缩文件
1.*.tar 用 tar –xvf 解压 2.*.gz 用 gzip -d或者gunzip 解压 3.*.tar.gz和*.tgz 用 tar –xzf 解压 4.*.bz2 用 bzip2 ...
- Qt 解压/压缩文件
很久没有在博客园写随笔了,今天项目需要解压和压缩文件,所以去了解哈. 参考的是大神的代码:https://yq.aliyun.com/articles/24428. 使用的是 QuaZIP类. 类 说 ...
- c# 用DotNetZip来解压/压缩文件
//https://archive.codeplex.com/?p=dotnetzip //最新在Nuget 下载DotNetZip using Ionic.Zip; private void but ...
- Ubuntu下解压压缩文件
1.ZIP解压 ZIP因为它的跨平台使用优点,是目前使用率最高的一种压缩方式,但是它的压缩率相比较tar.gz和tar.gz2来讲,却要低很多. 压缩命令:zip -r archive_n ...
- Linux 解压 压缩文件
来源于:http://blog.csdn.net/mmllkkjj/article/details/6768294/ 解压 tar –xvf file.tar //解压 tar包tar -xzvf f ...
- 解压压缩文件报错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 ...
- Bug :”解压压缩文件失败: cpio; 在头中不存在归档“
问题描述: 在rpm包目录下执行rpm -ivh *rpm -force时,出现标题错误 解决办法: *src.rpm包也就源码包不能被直接进行安装,需要先将src.rpm包进行编译生成二进制的rpm ...
随机推荐
- COJ 2108 Day7-例1
Day7-例1 难度级别:B: 运行时间限制:1000ms: 运行空间限制:256000KB: 代码长度限制:2000000B 试题描述 在计算机中,CPU只能和高速缓存Cache直接交换数据.当 ...
- 【最短路】BAPC2014 B Button Bashing (Codeforces GYM 100526)
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...
- socket(tcp)互发信息
一:有图有真相,很简单 a, b, Thread 构造函数(ParameterizedThreadStart)初始化 Thread 类的新实例,指定允许对象在线程启动时传递给线程的委托. 参数star ...
- Linux Zynq GPIO中断
注册中断:对每个pin进行循环遍历for (pin_num = 0; pin_num < min_t(int, ZYNQ_GPIO_NR_GPIOS, (int)chip->ngpio) ...
- poj1042
题目大意:去捕鱼 约翰去参加一个垂钓旅行,他有h小时可以使用在该地区有n (2 <= n <= 25) 个湖泊可以沿着一个单一的路到达,约翰从湖泊1开始,但是它可以在任何湖泊结束他如果想, ...
- UITextField知多少
//初始化textfield并设置位置及大小 UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(20, 20, 130, ...
- Mongodb快速入门之使用Java操作Mongodb
[IT168 专稿]在上一篇文章中,我们学习了Mongodb的安装和初步使用,在本文中,将学习如何使用Java去编程实现对Mongodb的操作. HelloWorld程序 学习任何程序的第一步,都是编 ...
- Libgdx New 3D API 教程之 -- Libgdx中使用Materials
This blog is a chinese version of xoppa's Libgdx new 3D api tutorial. For English version, please re ...
- 常用的bat命令
获取输入法adb shell settings get secure default_input_method修改输入法adb shell settings put secure default_in ...
- android string.xml前后加空格的技巧
方法1: <string name="password">密 码</string>  这个就代表着空格. 方法2:用\u0020代表空 ...