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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -