SharpZipLib是国外开源加压解压库,可以方便的对文件进行加压/解压 1.下载ICSharpCode.SharpZipLib.dll,并复制到bin目录下 http://www.icsharpcode.net/OpenSource/SharpZipLib/Download.aspx 2.编写工具类ZipUtil,一般放在App_Code文件夹下 using System; using System.Data; using System.Configuration; using System
一.使用ICSharpCode.SharpZipLib.dll: 下载地址 http://www.icsharpcode.net/OpenSource/SharpZipLib/Download.aspx 二.基于(ICSharpCode.SharpZipLib.dll)的文件压缩方法,类文件 压缩文件 using System; using System.IO; using System.Collections; using ICSharpCode.SharpZipLib.Checksums;
public static Stream CreateZip(List<string> listPath, int level = 5) { MemoryStream mstream = new MemoryStream(); using (ZipOutputStream zipstream = new ZipOutputStream(mstream)) { zipstream.SetLevel(level); Crc32 crc = new Crc32(); foreach (var pat
今天过中秋节,当地时间(2013-09-08),公司也放假了,正好也闲着没事,就在网上学习学习,找找资料什么的.最近项目上可能会用到压缩的功能,所以自己就先在网上学习了,发现一个不错的用于压缩的DLL文件,并且免费,而且开放源码: 这就是我今天介绍的对象: SharpZipLib 我们先看看它的官方介绍吧: #ziplib (SharpZipLib, formerly NZipLib) is a Zip, GZip, Tar and BZip2 library written entirely
首先通过NuGet管理安装ICSharpCode.SharpZipLib.dll 以下是压缩的通用方法: using System; using System.IO; using System.Web; using System.Linq; using System.Collections.Generic; using ICSharpCode.SharpZipLib.Zip; namespace Common { /// <summary> /// 压缩文件帮助类 /// </summa
using System; using System.Collections.Generic; using System.IO; using System.Text; using ICSharpCode.SharpZipLib.Checksums; using ICSharpCode.SharpZipLib.Zip; namespace Tools { public class SharpZipHelper { /// <summary> /// 存放待压缩的文件的绝对路径 /// </
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using ICSharpCode.SharpZipLib.Zip; using ICSharpCode.SharpZipLib.Checksums; using System.Security.Cryptography; namespace zip压缩与解压 { public class Z
这里我们选用ICSharpCode.SharpZipLib这个类库来实现我们的需求. 下载地址:http://icsharpcode.github.io/SharpZipLib/ 1.单个或多个文件加密压缩 class ZipClass { public void ZipFile(string FileToZip, string ZipedFile, int CompressionLevel, int BlockSize) { if (!System.IO.File.Exists(FileToZ