c# - Compression issue with large archive of files in DotNetZip -
greetings....
i writing backup program in c# 3.5, using hte latest dotnetzip. basics of program given location on server , max size of spanned zip file , go. there should traverse folder/files given location , add them archive, keeping exact structure. should compress down reasonable amount. given uncompressed collection of folders/files 10-25gb, created spanned files being limited 1gb each.
i have working (using dotnetzip). challenge there little no compession happening. chose use "adddirectory" method simplicity of code , how seemed fit project. after reading around second guessing decision.
given below code , large amount of files in archive, should compress each file added zip? or should adddirectory method provide same compression?
i have tried every level of compression offered ionic.zlib.compressionlevel , none seem help. should think using outside compression algorithm , stream dotnetzip file?
using (zipfile zip = new zipfile()) { zip.adddirectory(root.fullname); if (zippassword.length > 0) zip.password = zippassword; float size = zipgbsize * 1024 * 1024 * 1024; zip.compressionlevel = ionic.zlib.compressionlevel.bestcompression; zip.addprogress += new eventhandler<addprogresseventargs>(zip_addprogress); zip.ziperror += new eventhandler<ziperroreventargs>(zip_ziperror); zip.comment = "this zip created @ " + system.datetime.now.tostring("g"); zip.maxoutputsegmentsize = (int)size; //in gig zip.name = archivedir.fullname + @"\task_" + taskid.tostring() + ".zip"; zip.save(); }
thank help!
1.given below code , large amount of files in archive, should compress each file added zip?
the way dotnetzip works compress each file added archive. app not need compression. dotnetzip you.
or should adddirectory method provide same compression?
entries added zip file via adddirectory() method go through same code path when zip archive written, entries added via addfile(). file data compressed, optionally encrypted, written zip file.
an unsolicited tip: don't need do:
zip.addprogress += new eventhandler<addprogresseventargs>(zip_addprogress);
you can do:
zip.addprogress += zip_addprogress;
how determining no compression occurring?
if curious compression on each entry, can register saveprogress event handler. saveprogress event fired @ various times during writing of archive, including when saving begins, when dotnetzip begins writing data 1 entry, @ various intervals during writing of 1 entry, after finishing writing data each entry, , after finishing writing data. these stages , described in the zipprogresseventtype enumeration. when eventtype saving_afterwriteentry, can calculate compression ratio particular entry.
to verify compression not occurring, i'd suggest register such saveprogress event , @ compression ratio.
also, described above, file types cannot compressed. jpg, mpg, mp3, zip files, , others not compressible.
finally, doing backup may lots easier if use dotnetzip command-line tool. if want backup particular directory, use command line tool (zipit.exe) , avoid writing program. zipit.exe tool, if use -v option, tool prints progress reports, , display compression each entry, via mechanism described above. if prefer write own program, might consider using zipit.exe verify compression is, or not, occuring when use dotnetzip.
Comments
Post a Comment