How would i show the progress of compressing in SharpZipLib?
I'm developing a small application that Zip many file to a single zip file.
it may got a while to be done, there might be a progress bar that shows the progress of compressing, so is there a way to know how much has been compressed in SharpZipLib?
Asked
Active
Viewed 2,552 times
0

JasonMArcher
- 14,195
- 22
- 56
- 52

Murhaf Sousli
- 12,622
- 20
- 119
- 185
2 Answers
0
Yes you can see how much is compressed, by size of output stream, but that is not enought to show a progress bar, you should also know how big a output stream would be at the end, and of course you can't know that in advance.
You can measure progres when zipping individual files, and do that proportionaly by size of files, one file moves progress percentage by (size_of_file / total_size_of_all_files) * 100
For example let's say that you have 3 files :
file1.bin 1000 kb
file2.bin 500 kb
file3.bin 200 kb
after first file compressed move progres on 59%, after second file move it by 29% to 88% and after third to 100%.

Antonio Bakula
- 20,445
- 6
- 75
- 102
-
i think this's the meant solution for my application, because it's gonna be alot of small sized files, it doesn't matter how much it compressed for each file. – Murhaf Sousli Apr 22 '12 at 00:11
-
yes, I presume that progress bar will be smooth with that situation, btw. consider moving to DotNetZip, it's much easier to use then SharpZipLib – Antonio Bakula Apr 22 '12 at 00:27
-
ummm really!! i still new to zip stuff, some advice me to use SharpZipLib! check this out http://stackoverflow.com/questions/10263829/which-compression-type-should-i-choose-in-sharpziplib#comment13197644_10263829 – Murhaf Sousli Apr 22 '12 at 00:50
-
does DotNetZip has different types like TAR, GZIP, BZIP2 ...? – Murhaf Sousli Apr 22 '12 at 01:13
-
i think yes, but no TAR, not sure, see documentation – Antonio Bakula Apr 22 '12 at 01:34
0
If you use DotNetZip, there is a SaveProgress event that tells you how many bytes it has compressed.
There are code examples in the DotNetZip SDK showing how to use it.

Cheeso
- 189,189
- 101
- 473
- 713
-
-
Not tar. Zip, GZIP, BZIP2. But the progress events are specific to the Zip format. – Cheeso Apr 22 '12 at 01:47