Question

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?

Was it helpful?

Solution

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%.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top