Zip files in a folder using c# and return response -
i want zip files , folders in folder using c# , i've checked asked questions don't work me...i'm trying work dotnetzip. here's bit of code:
using (zipfile zip = new zipfile()) { string[] files = directory.getfiles(@"c:\users\t1132\desktop\logs"); // add files logs folder in zip file zip.addfiles(files, "logs"); zip.comment = "this zip created @ " + system.datetime.now.tostring("g"); var = system.datetime.now.tostring(); zip.save(@"c:\users\t1132\desktop\logs\archiver.zip"); foreach (var f in files) { system.io.file.delete(f); system.diagnostics.debug.writeline(f + "will deleted"); } }
the code above works zips files , leaves folders. kindly assist me please, thanks.
there many ways zip files using dotnetzip.
using (zipfile zip = new zipfile()) { zip.encoding = system.text.encoding.getencoding("big5"); // chinese zip.adddirectory(@"mydocuments\projectx"); zip.save(zipfiletocreate); }
above zips directory. more uses can follow links
https://dotnetzip.codeplex.com/wikipage?title=cs-examples&referringtitle=examples
or
http://grapevine.dyndns-ip.com/download/authentec/download/dotnetzip/examples.htm
thanks
Comments
Post a Comment