windows phone使用sharpcompress进行解压压缩文件
2014-05-25 16:17
447 查看
在做移动端时,当我们需要从服务器获得多个文件时,为了节约流量,服务器一般会返回一个压缩包,那我们就是下载完成后,在手机中进行解压到指定位置
SharpCompress就是可以在手机中进行解压一个类库(.net),在codeplex是开源,支持桌面端和移动端
点击下载最新版本 查看支持内容 API使用示例
下面我们看一下在windows phone中使用其进行解压ZIP包
其它的如RAR、Tar、GZip、7Zip可参考codeplex官方文档
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官方文档
相关文章推荐
- 使用C#2.0进行文件压缩和解压
- 使用C#2.0进行文件压缩和解压
- 【转载】使用C#2.0进行文件压缩和解压
- 使用ZLIB生成DLL文件,并进行有中文的ZIP文件压缩与解压操作!支持目录压与解!
- 使用PHP对文件进行压缩解压(zip)
- 【转】使用SevenZipSharp压缩、解压文件
- 使用SevenZipSharp压缩、解压文件
- 【转载】使用C#2.0进行文件压缩和解压
- 使用C#2.0进行文件压缩和解压
- 使用C#2.0进行文件压缩和解压(转)
- 使用apache的工具类进行zip(rar等压缩文件)的解压
- 使用ICSharpCode.SharpZipLib对文件进行压缩或解压
- SharpCompress的压缩文件解压和文件夹压缩
- 使用 C# 对文件进行压缩和解压
- 使用Zlib库进行文件的压缩和解压
- 使用C#进行文件压缩和解压
- 使用C#进行文件压缩和解压
- 使用GZIPOutputStream和GZIPInputStream进行压缩解压文件
- C#使用ICSharpCode.SharpZipLib.dll进行文件的压缩与解压功能
- Qt使用QuaZip对文件进行压缩解压操作