login about faq

I am extracting and then compressing a large set of dtaa in memory and then attaching them to an email as zipped csv's. I would like to record in my database how large the original extract was in KB.

Is there anyway to do this currently?

Thanks

jack

asked Jun 08 '12 at 15:46

Jack's gravatar image

Jack
1111


If you have a zip archive, you can use Chilkat Zip to open it (via the OpenZip method). Then iterate over the entries, getting each ZipEntry object, and then examine the ZipEntry.UncompressedLength property of each. This gives you the uncompressed size of each file contained within the .zip.

link

answered Jun 08 '12 at 18:21

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

some how I missed that... pretty easy.


     long size = 0;

for (var i = 0; i < zip.NumEntries; i++)
         size += zip.GetEntryByIndex(i).UncompressedLength64;

I'm assuming the directories return a length of 0... otherwise I have to exclude them.

It would be nice to be able to reference the entries as an IEnumerable<zipentry>

sizeInKb = zip.Entries.Where(x=>!x.IsDictionary).Sum(x=>x.UncompressedLength64/1024);

Anyhow I should be good to go with this...

thanks

link

answered Jun 09 '12 at 03:11

Jack's gravatar image

Jack
1111

edited Jun 10 '12 at 20:18

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×87

Asked: Jun 08 '12 at 15:46

Seen: 1,552 times

Last updated: Jun 10 '12 at 20:18

powered by OSQA