[
  {
    "Id": "183345",
    "ThreadId": "54393",
    "Html": "So, I have been using DotNetZip and love it!<br>\r\n<br>\r\nOne issue I'm having, though, is some of the .zip files I'm interfacing with have files stored within directories in the .zip.  I know where I want the individual files to go, regardless of what the directory structure is in the .zip file.  How can I specify where the actual file goes, instead of the location to unzip to?<br>\r\n<br>\r\nFor example, the zip files has contents like:<br>\r\n<br>\r\n[dir] 0000<br>\r\n[file]    --  0003_0294.jpg<br>\r\n[file]    --  0003_0394.jpg<br>\r\n...<br>\r\n<br>\r\nI know I want C:\\Temp\\0003_0294.jpg in a specific location.  But if I call <br>\r\n<br>\r\nZipFile.Extract( &quot;0000/0003_0294.jpg&quot;, &quot;C:\\\\Temp&quot; );<br>\r\n<br>\r\nThe file is location is C:\\Temp\\0000\\0003_0294.jpg.<br>\r\n<br>\r\nThanks for the help!<br>\r\n<br>\r\n--Chris\r\n",
    "PostedDate": "2009-04-24T11:23:23.95-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "183358",
    "ThreadId": "54393",
    "Html": "<span style=\"font-size:13px;color:#0000ff\">\r\n<p>Using </p>\r\n</span>\r\n<p><span style=\"font-size:13px\">zip1 </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> ZipFile = ZipFile.Read(ZipToUnpack)\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p> </p>\r\n</span></p>\r\n<p>\r\n<p><span style=\"font-size:13px;color:#0000ff\">Dim</span><span style=\"font-size:13px\"> e </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> ZipEntry </span></p>\r\n</p>\r\n<p> <span style=\"font-size:13px;color:#0000ff\">Dim</span><span style=\"font-size:13px\"> newfilename </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">String </span></p>\r\n<p> <span style=\"font-size:13px;color:#0000ff\">For</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">Each</span><span style=\"font-size:13px\"> e </span><span style=\"font-size:13px;color:#0000ff\">In</span><span style=\"font-size:13px\"> zip1 </span></p>\r\n<p> <span style=\"font-size:13px;color:#0000ff\">Dim</span><span style=\"font-size:13px\"> s </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">String</span><span style=\"font-size:13px\"> = e.FileName </span></p>\r\n<p> <span style=\"font-size:13px;color:#0000ff\">Dim</span><span style=\"font-size:13px\"> pathend </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">Integer</span><span style=\"font-size:13px\"> = s.LastIndexOf(</span><span style=\"font-size:13px;color:#a31515\">&quot;/&quot;</span><span style=\"font-size:13px\">) + 1 </span></p>\r\n<p> <span style=\"font-size:13px;color:#0000ff\">Dim</span><span style=\"font-size:13px\"> filename </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">String</span><span style=\"font-size:13px\"> = s.Substring(pathend)<br>\r\n<span style=\"font-size:13px\">newfilename = </span><span style=\"font-size:13px\"> filename </span>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p> <span style=\"font-size:13px\">e.FileName = newfilename<br>\r\n<span style=\"font-size:13px;color:#0000ff\">Dim</span><span style=\"font-size:13px\"> ex </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> ExtractExistingFileAction = ExtractExistingFileAction.OverwriteSilently\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>e.Extract(UnpackDirectory, ex)<br>\r\nnext<br>\r\n<br>\r\nthis is working for me, though Im using ver 1.8 so your e.extract is a little different in earlier versions I think, anyway filename gives you the actual filename minus all the path(s). UnpackDirectory would be c:/temp in your case probably</p>\r\n</span>\r\n<p>&nbsp;</p>\r\n<p> </p>\r\n<p> </p>\r\n</span></p>\r\n</span></p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p> </p>\r\n",
    "PostedDate": "2009-04-24T12:00:48.313-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "183364",
    "ThreadId": "54393",
    "Html": "Unfortunately I'm using v1.6, so there are a few problems with the code:<br>\r\n<br>\r\n    - e.Filename is read-only<br>\r\n    - I tried calling zip1.UpdateFile( e.Filename, &quot;&quot; ) to change the directory, but this modifies the collection, which invalidates the enumerator on the next pass<br>\r\n<br>\r\nAlso, is there a way to get a ZipEntry instance without enumerating over the collection?<br>\r\n<br>\r\n--Chris\r\n",
    "PostedDate": "2009-04-24T12:14:47.85-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "183367",
    "ThreadId": "54393",
    "Html": "I just happened on this site yesterday so thats about the limit of my knowledge , sorry , pretty sure there is a way to get the zipentry by name(or index I think) , but you'd have to know the filename ahead of time or loop thru the zip file to get all the filenames/indexes anyway I think, 1.8 seems to be fine so far for me so you might want to upgrade unless youve got a body of code using the older version I guess\r\n",
    "PostedDate": "2009-04-24T12:27:54.353-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "184601",
    "ThreadId": "54393",
    "Html": "Flyncode, to answer your question, if the zip file encodes a location for a particular entry, then you have to take special action when extracting if you do NOT  want to extract into that location. As you saw, you can specify the root directory for the extraction, but the path for the ZipEntry is used when extracting. <br>\r\n<br>\r\nI can see a couple easy options:<br>\r\n<ul>\r\n    <li>extract the entry to a FileStream, which you open to the path you desire. </li>\r\n    <li>Extract to a temp location and then rename (remap) files. </li>\r\n</ul>\r\n<br>\r\nUsing later versions of the library you can change the FileName on the entry and then extract, but this won't work on v1.6, as you already pointed out. <br>\r\n",
    "PostedDate": "2009-04-28T10:07:27.1-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]