• 您的位置我爱Aspx >> VC.Net >> 利用SharpZipLib实现实时zip压缩下载整个目录
  • 利用SharpZipLib实现实时zip压缩下载整个目录

  • 作者:aspxer  来源:internet  日期:2007-5-21 23:49:04  关键字:
  • 利用SharpZipLib实现实时zip压缩下载整个目录

    整个目录,一般方法是一个个文家下载或ftp工具

    现在用SharpZipLib就能实现实时zip压缩下载整个目录

    SharpZipLib提供了多种压缩算法的支持,纯csharp代码,参见

    原理是通过递归方法将每个文件压缩到ZipOutputStream,然后下载

    代码和范例如下:

    <%@ Import namespace="ICSharpCode.SharpZipLib.Zip" %>

    <%@ Import Namespace="System.IO" %>

    <script language="c#" runat="server">

    ZipOutputStream zos=null;

    String strBaseDir="";

    void dlZipDir(string strPath,string strFileName){

    MemoryStream ms =null;

    Response.ContentType = "application/octet-stream";

    strFileName=HttpUtility.UrlEncode(strFileName).Replace(´+´,´ ´);

    Response.AddHeader("Content-Disposition", "attachment; filename=" + strFileName+".zip");

    ms = new MemoryStream();

    zos = new ZipOutputStream(ms);

    strBaseDir=strPath+"\\";

    addZipEntry(strBaseDir);

    我对这篇文章有话说?
  • 广告位招租,广告代号:content_468_15
  • 上一篇:关于杠杆长度变化的问题(C问题)
    下一篇:简单分析用SPI实现防火墙
  • 相关文章