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 ...
随机推荐
- java学习面向对象之this
在我们讲构造函数的时候,我们知道,如果同时在java的堆内存当中,同时存在好几个刚进内存,但是又没来得及初始化的同一个类的对象.在这种情况下,那么如何去区分栈内存当中的构造函数是属于那个对象的呢,其实 ...
- 数据结构:HDU 2993 MAX Average Problem
MAX Average Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- Evaluate Reverse Polish Notation——LeetCode
Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, ...
- HDOJ(HDU) 2401 Baskets of Gold Coins(数列、)
Problem Description You are given N baskets of gold coins. The baskets are numbered from 1 to N. In ...
- ltp工具使用配置
ltp是一个比较全的自然语言处理工具,可以用它进行分词.词性标注.语法分析等任务. ---- 准备 下载 下载ltp和ltp4j,在cmake官网下载并安装相应版本的cmake,并且下载ant. 构建 ...
- C++ static(施工中)
static 变量 头文件中的static会在引用该头文件的cpp中分别生成副本 //H.h #ifndef _H_H_ #define _H_H_ ; #endif //Ex_2.c #includ ...
- 拥有最小高度能自适应高度,IE、FF全兼容的div设置
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " http://www.w3.org/TR/xh ...
- Mysql binlog日志解析
1. 摘要: Mysql日志抽取与解析正如名字所将的那样,分抽取和解析两个部分.这里Mysql日志主要是指binlog日志.二进制日志由配置文件的log-bin选项负责启用,Mysql服务器将在数据根 ...
- 两种动态载入修改后的python模块的方法
方案一:循环导入/删除模块 a.py import sys, time while True: from b import test test() del sys.modules(b) time.sl ...
- centos下的mysql安装
卸载mysql yum remove mysql mysql-server mysql-libs compat-mysql51 rm -rf /var/lib/mysql rm /etc/my.cnf ...