[英]On-the-fly zipping using Ionic.Zip c#
我試圖從流中創建一個zip文件,並返回一個流,但我的問題是我不想在本地硬盤或內存中存儲任何數據。 我正在使用Ionic.Zip
庫
Stream output = new MemoryStream();
using (ZipFile zip = new ZipFile())
{
Stream s = ftpManager.GetFileStream("/mydoc.docx");
ZipEntry e = zip.AddEntry("Content-From-Stream.bin", s);
e.Comment = "The content for entry in the zip file was obtained from a stream";
//zip.AddFile("Readme.txt");
zip.Save(output);
}
if (output != null)
{
ftpManager.Upload(output, "/MohamedTest/mydoc.zip");
}
該代碼有很多問題,
有什么建議么
壓縮后,輸出上最可能的位置設置為流的末尾,請檢查此位置。 並且,除非您實現一些代理流(將處理.Write方法並將此數據發送到FTP),否則您需要內存/文件流來存儲壓縮后的數據。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.