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 修复一下又可以了。 用其他的 其他没问题。有遇到的朋友吗?
重新找了压缩方法