首页 新闻 会员 周边

ICSharpCode 压缩文件crc32都是00000损坏问题

0
悬赏园豆:10 [已关闭问题] 关闭于 2017-03-16 10:26

code:

复制代码
        /// <summary>
        /// 压缩文件并输出到客户端提供下载
        /// </summary>
        /// <param name="zipFileList">压缩文件辅助实体类</param>
        /// <param name="zipName">整个压文件的文件名 不用带后缀</param>
        public static void ZipDownLoad(List<ZipEntity> zipEntity, string zipName)
        {
            MemoryStream ms = new MemoryStream();
            using (ZipFile zip = new ZipFile(ms))
            {
                zip.BeginUpdate();
                foreach (var item in zipEntity)
                {
                    zip.Add(item.FileFullPath, item.FileNewName);
                }

                zip.CommitUpdate();
                zipName += ".zip";
                //zipName = HttpUtility.UrlEncode(System.Text.UTF8Encoding.UTF8.GetBytes(zipName));

                HttpResponse response = System.Web.HttpContext.Current.Response;
                response.ContentType = "application/zip";
                response.AddHeader("Content-Disposition", string.Format("attachment; filename=" + zipName));
                response.BinaryWrite(ms.GetBuffer());
                ms.Close();
                ms.Dispose();
             
                try { response.Flush(); }
                catch { }
                finally
                {
                    System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest();
                }
        
                response.End();
            }
        }
复制代码

rar解压 提示文件损坏。其中 crc32都是0 修复一下又可以了。 用其他的 其他没问题。有遇到的朋友吗?

s_p的主页 s_p | 初学一级 | 园豆:138
提问于:2017-03-13 16:03
< >
分享
所有回答(1)
0

重新找了压缩方法

s_p | 园豆:138 (初学一级) | 2017-03-16 10:14
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册