日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

SharpZipLib 压缩ZIP导出

發布時間:2023/12/18 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SharpZipLib 压缩ZIP导出 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1      var uploadSectionDir = Path.Combine("Upload", "QQ", DateTime.Now.ToString("yyyyMMdd")); 2 string uploadDir = Path.Combine(HttpRuntime.AppDomainAppPath, uploadSectionDir); 3 if (!Directory.Exists(uploadDir)) 4 { 5 Directory.CreateDirectory(uploadDir); 6 } 7 string fileName ="test.zip"; 8 string filePath = Path.Combine(uploadDir, fileName); 9 10 //生成的壓縮文件為test.zip 11 using (FileStream fsOut = System.IO.File.Create(filePath)) 12 { 13 //ZipOutputStream類的構造函數需要一個流,文件流、內存流都可以,壓縮后的內容會寫入到這個流中。 14 using (ZipOutputStream zipStream = new ZipOutputStream(fsOut)) 15 { 16 MemoryStream ws = new AirBillBLL().ExportToExcel(ladingNoList); 17 string entryName = string.Concat(string.Format("{0:yyyyMMddHHmmssffff}", DateTime.Now), ".xls"); 18 ZipEntry newEntry = new ZipEntry(entryName); 19 newEntry.DateTime = DateTime.Now; 20 newEntry.Size = ws.Length; 21 22 //把壓縮項的信息添加到ZipOutputStream中。 23 zipStream.PutNextEntry(newEntry); 24 byte[] buffer = new byte[4096]; 25 //把需要壓縮文件以文件流的方式復制到ZipOutputStream中。 26 27 StreamUtils.Copy(ws, zipStream, buffer); 28 29 zipStream.CloseEntry(); 30 zipStream.IsStreamOwner = false; 31 zipStream.Finish(); 32 zipStream.Close(); 33 } 34 }
35 return File(filePath, "application/x-zip-compressed", string.Concat(string.Format("{0:yyyyMMddHHmmssffff}", DateTime.Now), ".zip"));

?

轉載于:https://www.cnblogs.com/LiuFengH/p/9862309.html

總結

以上是生活随笔為你收集整理的SharpZipLib 压缩ZIP导出的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。