[
  {
    "Id": "637960",
    "ThreadId": "264053",
    "Html": "\r\n<p>Hi,</p>\r\n<p>I tried to use DotNetZip Library today to create a zip file out of a bunch of files on my hard drive. Apparently not all files are included once I decide to write the zip file to disc.</p>\r\n<p>This is my setup:</p>\r\n<p></p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre><span style=\"color:blue\">public</span> <span style=\"color:blue\">class</span> ZippedFile\r\n{\r\n    <span style=\"color:blue\">public</span> <span style=\"color:blue\">static</span> ZipFile Create(<span style=\"color:blue\">string</span> xmlFilepath)\r\n    {\r\n        <span style=\"color:blue\">var</span> zippedFile = <span style=\"color:blue\">new</span> ZipFile();\r\n\r\n        zippedFile.Add(xmlFilepath);\r\n\r\n        <span style=\"color:green\">// Code to get the list with all files to include out of the xml file</span>\r\n        <span style=\"color:green\">// files is a List&lt;string&gt; with filepath's</span>\r\n\r\n        <span style=\"color:blue\">foreach</span>(<span style=\"color:blue\">string</span> file <span style=\"color:blue\">in</span> files)\r\n        {\r\n            zippedFile.Add(file);\r\n        }\r\n        <span style=\"color:blue\">return</span> zippedFile;\r\n    }\r\n\r\n\r\n<span style=\"color:blue\">public</span> <span style=\"color:blue\">class</span> Test\r\n{\r\n\r\n    <span style=\"color:blue\">public</span> Test(<span style=\"color:blue\">string</span> filepath)\r\n    {\r\n        ZipFile myZip = ZippedFile.Create(filepath);\r\n        myZip.Save(<span style=\"color:#a31515\">@&quot;C:\\test.zip&quot;</span>);\r\n    }\r\n\r\n}\r\n</pre>\r\n</div>\r\n<p></p>\r\n<p>If I set a break point right before it saves the zip file at line myZip.Save(@&quot;C:\\test.zip&quot;) I see 29 Entries being listed which is the right amount of files. The create zip file however only contains 3 files and an empty folder which should normally contain\r\n a bunch of the 29 files.</p>\r\n<p>Any suggestions?</p>\r\n",
    "PostedDate": "2011-07-06T01:57:24.053-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "638145",
    "ThreadId": "264053",
    "Html": "<p>yes, I have a suggestion. Use the ZipFile class in a using clause.&nbsp; Check any of the examples shown on <a href=\"http://dotnetzip.codeplex.com/wikipage?title=Examples&amp;referringTitle=Documentation\">the examples page</a>, or any of the example code in the documentation.&nbsp;</p>\r\n<div style=\"color: black; background-color: white;\">\r\n<pre><span style=\"color: blue;\">using</span> (<span style=\"color: blue;\">var</span> zippedFile = <span style=\"color: blue;\">new</span> ZipFile())\r\n{\r\n    zippedFile.AddFile(.....);\r\n    zippedFile.Save(<span style=\"color: #a31515;\">\"PathToZippedFile.zip\"</span>);\r\n}\r\n</pre>\r\n</div>\r\n<p>You need to call .Dispose() on the ZipFile instance for it to properly close its destination stream. This is as documented. Employing a using clause calls .Dispose() implicitly, and is the easiest way to do what you need to do.</p>",
    "PostedDate": "2011-07-06T07:32:11.55-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "638737",
    "ThreadId": "264053",
    "Html": "<p>Apparently this does not solve my problem. I start thinking that DotNetZip Library has a problem adding files without extensions since all files missing in the created zip files are those which have no file extension.</p>",
    "PostedDate": "2011-07-07T07:02:58.323-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "638952",
    "ThreadId": "264053",
    "Html": "<p>I just checked explicitly - and DotNetZip has no problem zipping files with no extension.&nbsp;</p>\r\n<p>There is something else causing your problem. Are you sure the files are not present?&nbsp; You wrote:&nbsp; \"<em>The create zip file however only contains 3 files and an empty folder which should normally contain a bunch of the 29 files.</em>\"&nbsp; How did you verify this?&nbsp;&nbsp; Can you check with DotNetZip (ZipFile.Read())?&nbsp; If you can produce a small application that illustrates the problem - something I can run on my computer - we will be able to diagnose it pretty quickly.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2011-07-07T11:54:07.52-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "639250",
    "ThreadId": "264053",
    "Html": "<p>I have solved the problem or at least was able to get it work.</p>\r\n<p>File structure:</p>\r\n<p>C:\\test\\test.xml<br />C:\\test\\subdir\\1<br />C:\\test\\subdir\\2<br />C:\\test\\subdir\\3<br /> C:\\test\\subdir\\4<br />C:\\test\\subdir\\5<br /> C:\\test\\subdir\\6</p>\r\n<p>test.xml contains the file path for every other file. Now when I simple do the foreach loop over all path arguments using the simple Add(string path) I end up with just the text.xml file and an empty subdir folder in my zipFile (although debugging showed, that right before .Save() all file entries are in my ZipFile. However not after the file was written to disk. To be able to get all my files in the ZipFile I have to use the .Add(string path, \"\") version to explicitly tell DotNetZip Library that I want all files in my root document of the zip file. I just assumed that's the default behavior if I don't provide a directoryPathInZip.</p>",
    "PostedDate": "2011-07-07T23:07:05.807-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "639517",
    "ThreadId": "264053",
    "Html": "<p>I'm glad you got it working.&nbsp;&nbsp; Seems like it was a misunderstanding or bad assumption on your part.&nbsp; Your assumption that entries would appear in the root of the zip archive was incorrect.</p>\r\n<p>Stepping back, I always try to make sure that DotNetZip behaves correctly, as it is documented to behave.&nbsp; You're reporting that it is not behaving correctly, though you found a way to work around that broken behavior.&nbsp; If you are interested, I still would like to get a test case from you that reproduces the incorrect behavior.&nbsp; You mentioned \"an empty subdir folder in the zipfile\".&nbsp; If you can provide a small test case that reproduces that particular&nbsp;problem, I would be glad to fix it.&nbsp;</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2011-07-08T08:43:40.263-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]