我的应用程序中有以下代码部分。我想将压缩文件大小存储在DB中,但是当我存储缓冲区值时,它与压缩的zip文件大小不同。
如何在C#中识别确切的Zip文件大小?
using (ZipFile zip = new ZipFile())
{
zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
foreach (Docs Docs in FileByteCollection)
{
doctype = "Insured";
country = "US";
if (doctype == "Local")
Docs.DocumentName = "LocalDoc.pdf";
else if (doctype != "Local")
Docs.DocumentName = "Interantional.pdf"
zip.AddEntry(Docs.DocName, Docs.DocumentContent);
}
zip.Save(outputMemStream);
}
获取FileSize的当前逻辑:
byte[] byteArr = ((MemoryStream)outputMemStream).ToArray();
int totalSize = 0;
foreach (byte b in byteArr)
totalSize = totalSize + b;