• 多选打包下载


    using Ionic.Zip;
    /////////////////在对多文件打包中用到了 DotNetZip 的方法来实现对多文件压缩打包。需要到http://dotnetzip.codeplex.com/处下载该文件,然后引用Ionic.Zip即可
        public void PackDown()
        {
            string fileUrls = "/UploadFiles/CallRecord/201412/20141203172322375.mp3|/UploadFiles/CallRecord/201412/20141203172304379.mp3|";
            if (fileUrls.Length > 0)
                fileUrls = fileUrls.Remove(fileUrls.Length - 1);
            string[] Directories = System.Text.RegularExpressions.Regex.Split(fileUrls, "\|");
     
            Response.Clear();
            Response.ContentType = "application/zip";
            Response.AddHeader("content-disposition", "filename=DotNetZip.zip");
            using (ZipFile zip = new ZipFile(System.Text.Encoding.Default))//解决中文乱码问题  
            {
                for (int i = 0; i < Directories.Length; i++)
                {
                    try
                    {
                        string fileUrl = HttpContext.Current.Server.MapPath("~" + Directories[i]);
                        zip.AddFile(fileUrl, "");
                    }
                    catch (Exception ex)
                    {
                    }
                }
                zip.Save(Context.Response.OutputStream);
            }
            Response.End();
        }
  • 相关阅读:
    HTML 页面的 批量删除的按钮
    HTML 选择器
    ....
    java 反射机制
    插件库
    向上滚动
    浮动元素定位float
    中文字体对应的英文名称
    echarts入门教程
    ie9浏览器window.openbug
  • 原文地址:https://www.cnblogs.com/deep-blue/p/5109958.html
Copyright © 2020-2023  润新知