首先了解ZipOutPutStream和ZipEntry对象 ZipOutPutStream对象 如果要完成一个文件或文件夹的压缩,则要使用ZipOutputStream类.ZipOutputStream是OutputStream的子类,常用操作方法如表12-20所示.ZipOutputStream类的常用方法 序号 方    法 类型 描    述 1 public ZipOutputStream (OutputStream out) 构造 创建新的ZIP输出流 2 public void p…
官网http://www.icsharpcode.net/ 支持文件和字符压缩. 创建全新的压缩包 第一步,创建压缩包 using ICSharpCode.SharpZipLib.Zip; ZipOutputStream zipOutputStream = new ZipOutputStream(File.Create(strZipPath)); 参数:strZipPath,提供压缩后的文件包全路径,即地址和文件名.如,D:\tmp\01.rar第二步,向压缩包中添加压缩包的文件名 ICShar…
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.dll下载地址 1.压缩某个指定文件夹下日志,将日志压缩到CompressionDirectory文件夹中,并清除原来未压缩日志. #region 压缩logs文件夹下日志 public static void CompresslogDic() { try { string logFilePath = AppDomain.CurrentDomain.BaseDirectory + "logs"; DirectoryInfo logsDic…
原文:基于ICSharpCode.SharpZipLib.Zip的压缩解压缩 今天记压缩解压缩的使用,是基于开源项目ICSharpCode.SharpZipLib.Zip的使用. 一.压缩: /// <summary> /// 压缩 /// </summary> /// <param name="sourceDirectory"></param> /// <param name="targetZipName"&g…
使用开源类库ICSharpCode.SharpZipLib.Zip可以实现压缩与解压缩功能,源代码和DLL可以从http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx下载: 有两种方式可以实现压缩与解压缩,这里只提供了ZIP格式: 1.DLL本身提供的快速压缩与解压缩,直接代码: using System; using ICSharpCode.SharpZipLib.Zip; namespace Zip { public st…
最近想用个解压缩功能 从网上找了找 加自己修改,个人感觉还是比较好用的,直接上代码如下 using System; using System.Linq; using System.IO; using ICSharpCode.SharpZipLib.Zip; using ICSharpCode.SharpZipLib.Checksums; using System.Diagnostics; using Microsoft.Win32; namespace ZipCommon { public cl…
写了一个小程序利用NPOI来读取Excel,弹出这样的报错: ICSharpCode.SharpZipLib.Zip.ZipException:Wrong Local header signature 原因在于读取Excel的时候若是读取的文件为txt或者其他拓展名时,都会报这样不知所措的异常: 所以只需要在读取时先检查一下文件名的拓展名,把非.xls和.xlsx的文件过滤就可以了.…
public class ZipFileHelper { List<string> urls = new List<string>(); void Director(string dir) { DirectoryInfo d = new DirectoryInfo(dir); FileSystemInfo[] fsinfos = d.GetFileSystemInfos(); foreach (FileSystemInfo fsinfo in fsinfos) { if (fsin…
//压缩整个目录下载 var projectFolder = Request.Params["folder"] != null ? Request.Params["folder"] : string.Empty; if (!string.IsNullOrWhiteSpace(projectFolder)) { string path = Util.GetMapPath(string.Format("attarch/html/{0}", proje…