.net 3.5 - Zipping files preserving the directory structure -


i using dotnetzip dll(http://dotnetzip.codeplex.com/) codeplex zip files in program.

problem facing after zipping files preserving directory structure , when extracting zip file parent folders getting created again , able view file. annoying when source file exists in

so, if zipping file g:\archive\logfiles\w3svc1\abc.log , creating 'abc.zip' file after extracting it, folders archive\logfiles\w3svc1\ getting created , able see abc.log file. here 'g:' name of shared drive.

i want rid of these parent folders can straight away extract , reach zipped file , open it. have checked path property of zipped file , showing archive\logfiles\w3svc1. somehow need remove programatically not finding option easily.

code using this:

using (zipfile zip = new zipfile()) {     if (fileextension != null)     {         zip.addfiles(from f in sourcedir.getfiles() f.fullname.endswith(fileextension) select f.fullname);     }     else     {         zip.addfiles(from f in sourcedir.getfiles() select f.fullname);     }     zip.save(destinationdir + outfilename); } 

i have tried overload method of addfiles setting reservedirectoryhierarchy 'false' no benefit.

please let me know do.

many in advance.

i not calling overload method of addfiles properly. instead of null passed empty string , not preserving directory structure. updated code below:

if (fileextension != null)                 {                     zip.addfiles(from f in sourcedir.getfiles() f.fullname.endswith(fileextension) select f.fullname,false,"");                  }                 else                 {                     zip.addfiles(from f in sourcedir.getfiles() select f.fullname,false,"");                 }                 zip.save(destinationdir + outfilename); 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -