I have below section of code in my application. I would like to store Zipped file size in DB but when I store buffer value it is different from compressed zip file size.
How to identify exact Zip file size in C#?
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);
}
Current logic to get FileSize:
byte[] byteArr = ((MemoryStream)outputMemStream).ToArray();
int totalSize = 0;
foreach (byte b in byteArr)
totalSize = totalSize + b;