[
  {
    "Id": "676686",
    "ThreadId": "273847",
    "Html": "\r\n<p>Hi,</p>\r\n<p>I have a photoalbum and I'm using a zip file to add&nbsp;the images to the album. &nbsp;As long as the zip file contains no directories, it all goes fine. &nbsp;</p>\r\n<p>But let's say I have zip file like this;</p>\r\n<p style=\"padding-left:30px\">album.zip</p>\r\n<p>containing</p>\r\n<p style=\"padding-left:30px\">1.jpg</p>\r\n<p style=\"padding-left:30px\">2.jpg</p>\r\n<p style=\"padding-left:30px\">sub/3.jpg</p>\r\n<p style=\"padding-left:30px\">sub/sub/4.jpg</p>\r\n<p>Is there a way to extract all the jpgs at the root level of the unpackfolder? &nbsp;Meaning that it ignores the directories in the zip, and extract jpg's only.</p>\r\n<p>If I do it like this, it's takes the directory structure into the unpackDirectory.</p>\r\n<p></p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre>    <span style=\"color:blue\">foreach</span> (ZipEntry e <span style=\"color:blue\">in</span> zip)\r\n    {\r\n          e.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently);                                   \r\n    }\r\n</pre>\r\n</div>\r\n<p></p>\r\n<p>I need a way to remove the preceding folder path before extracting... &nbsp;any ideas?</p>\r\n",
    "PostedDate": "2011-09-26T06:46:48.75-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "676968",
    "ThreadId": "273847",
    "Html": "<p>Try something like this:</p>\r\n<div style=\"color: black; background-color: white;\">\r\n<pre>    <span style=\"color: blue;\">foreach</span> (ZipEntry e <span style=\"color: blue;\">in</span> zip)\r\n    {\r\n          e.FileName = Path.GetFileName(e.FileName);\r\n          e.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently);                                   \r\n    }\r\n\r\n</pre>\r\n</div>",
    "PostedDate": "2011-09-26T21:33:09.98-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "677019",
    "ThreadId": "273847",
    "Html": "<p>Thanks, got there with your tip and this article;&nbsp;<a href=\"http://blogs.planetcloud.co.uk/mygreatdiscovery/post/Flattening-a-directory-structure-with-DotNetZip.aspx\">http://blogs.planetcloud.co.uk/mygreatdiscovery/post/Flattening-a-directory-structure-with-DotNetZip.aspx</a></p>\r\n<p>Following code worked for me :</p>\r\n<p>\r\n<div style=\"color: black; background-color: white;\">\r\n<pre><span style=\"color: blue;\">using</span> (ZipFile zip = ZipFile.Read(path + zipToUnpack))\r\n{\r\n    <span style=\"color: green;\">// here, we extract every entry, but we could extract conditionally</span>\r\n    <span style=\"color: green;\">// based on entry name, size, date, checkbox status, etc.  </span>\r\n    <span style=\"color: blue;\">foreach</span> (ZipEntry e <span style=\"color: blue;\">in</span> zip.EntriesSorted)\r\n    {\r\n        <span style=\"color: blue;\">try</span>\r\n        {\r\n            e.FileName = Path.GetFileName(e.FileName);\r\n            e.Extract(unpackDirectory, ExtractExistingFileAction.OverwriteSilently);\r\n        }\r\n        <span style=\"color: blue;\">catch</span> { <span style=\"color: blue;\">continue</span>; }\r\n    }\r\n} <span style=\"color: green;\">// end using</span></pre>\r\n</div>\r\n</p>",
    "PostedDate": "2011-09-27T00:48:40.23-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]