zoukankan      html  css  js  c++  java
  • asp.net for itextsharp 操作pdf

     今天分享下昨天做的一个东西 asp.net 的文件  zip 批量下载,首先你需要去 到http://dotnetzip.codeplex.com这个站点下载zip 的包,在里面找到 Ionic.Zip.dll  引用到你的项目中去
    
          
    
    
    
      /// <summary>
        /// 批量zip下载
        /// </summary>
        /// <param name="Listimg">这里Listimg 是一个数组类型</param>
        public void CreateZip(string Listimg)
        {
            string[] imgs = Listimg.Split(',');
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.BufferOutput = false;
    
    
    
     //网站文件生成一个readme.txt的自述文件(可以不写)
        String readmeText = String.Format("README.TXT" +Environment.NewLine+"网址址:http://aicoffees.com"   );
    
    
    
            HttpContext.Current.Response.ContentType = "application/zip";//以zip 形式输出
            HttpContext.Current.Response.AddHeader("content-disposition", "inline; filename="Photo.zip");//压缩下载的名字
    
            //批量压缩操作
            using (ZipFile zip = new ZipFile())
            {
                for (int i = 0; i < imgs.Length; i++)
                {
    
    
    
    ///在压缩包内添加上面的自述文件,文字编码是系统默认编码形式
    
     zip.AddEntry("Readme.txt", readmeText, Encoding.Default);
    
    
    
    
            zip.Password = "aicoffees.com";//给压缩包设置密码
            zip.Encryption = EncryptionAlgorithm.WinZipAes256;//加密方式
    
    
    
    
    
    
    
                 zip.AddFile(HttpContext.Current.Server.MapPath(imgs[i].ToString()), "");//这里"" 我给的是空就是压缩时不设置文件夹,如果需要取什么名字只需要在“”里面加上就可以了,这里是一个重载方法,如果
    
     zip.AddFile(HttpContext.Current.Server.MapPath(imgs[i].ToString()), "");这样写的话,zip 就会默认把你的image从根目录一直压缩到你的文件所在目录。
    
               
                }
                zip.Save(HttpContext.Current.Response.OutputStream);
    
            }
            HttpContext.Current.Response.Close();
    
        }
    
    
    
    以上是自己的一点小总结,come on
  • 相关阅读:
    物联网操作系统HelloX V1.77(beta)版本发布
    对XX证券报关于物联网操作系统的几个问题的答复
    Android利用广播实现ViewPager中item之间的数据通信
    Android创建桌面快捷方式
    Android时间选择器对话框的使用
    Android数据库LitePal的存储操作
    Android创建数据表和LitePal的基本用法
    我的2014
    logstash 安装zabbix插件
    tag_on_failure => [] # prevent default _grokparsefailure tag on real records
  • 原文地址:https://www.cnblogs.com/yiliuyang/p/4253247.html
Copyright © 2011-2022 走看看