[
  {
    "Id": "669745",
    "ThreadId": "272079",
    "Html": "<p>I'm not sure if the topic makes sense, but I have a list of strings, file paths:</p>\n<p>c:\\temp\\1.txt<br /> c:\\temp\\2.txt<br /> c:\\temp\\dir\\1.txt<br /> c:\\temp\\dir\\2.txt</p>\n<p>I want to have a single method that I can pass this list of strings to in create an output zip file like:</p>\n<p>1.txt<br /> 2.txt<br /> dir\\1.txt<br /> dir\\2.txt</p>\n<p>where the dir is a directory in the zip file. &nbsp;Basically I &nbsp;want to preserve the directory structure at the highest level, I don't want a temp folder in my zip file.&nbsp;</p>\n<p>Any ideas?</p>",
    "PostedDate": "2011-09-09T08:52:39.417-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "669904",
    "ThreadId": "272079",
    "Html": "<p>Well it seems to me to be a pretty simple matter.&nbsp; you just want some portion of the directory to be trimmed for each entry.&nbsp; If it's the same portion for each entry, then it's pretty easy.&nbsp; For example, this code just trims off the toplevel directory off the entry to be added. You could use similar logic for different requirements.</p>\r\n<div style=\"color: black; background-color: white;\">\r\n<pre><span style=\"color: blue;\">private</span> <span style=\"color: blue;\">void</span> AddZipEntryTrimmed(<span style=\"color: blue;\">string</span> fullFileName)\r\n{\r\n    <span style=\"color: blue;\">int</span> len = fullFileName.Length;\r\n    <span style=\"color: blue;\">int</span> ix = fullFileName.IndexOf('\\');\r\n    <span style=\"color: blue;\">string</span> trimmedEntryName= fullFileName.Substring(ix+1,len);\r\n    <span style=\"color: blue;\">var</span> e = zipFile.AddFile(fullFileName);\r\n    e.FileName = trimmedEntryName;\r\n}\r\n\r\n</pre>\r\n</div>",
    "PostedDate": "2011-09-09T14:18:17.123-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "669910",
    "ThreadId": "272079",
    "Html": "<p>Well I guess I'm looking for a way to do this more generically since I'm using this in quite a few places.&nbsp;I have a method like this</p>\r\n<p>void ZipFiles(List&lt;string&gt; files, string output); That I want to build that logic in to.</p>\r\n<p>I guess I can just loop through the files and find the highest directory structure that they all use and strip them out that way, just seems silly i guess when you realize that most of the time when you are using a GUI zip program, you do this and it works magically. Ie. Navigate to a folder on your file system, drag and select a few files and a folder and right click and hit Send to Zip. Voila it works and is exactly the functionality i'm looking to do.&nbsp;</p>",
    "PostedDate": "2011-09-09T14:39:10.363-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "670293",
    "ThreadId": "272079",
    "Html": "<p>you can do the equivalent of \"navigate to a folder\" in an application by calling Directory.SetCurrentDirectory() .&nbsp; In DotNetZip if you then make your calls to AddFile() or AddEntry(), etc, you can use relative paths and the library will use that relative path within the archive.</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2011-09-11T09:31:34.95-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]