[
  {
    "Id": "83004",
    "ThreadId": "24764",
    "Html": "\r\nIf I build a directory that contains only subdirectories and no top level files, such as:<br /><br />C:\\zipme\\subdir1\\<br />C:\\zipme\\subdir1\\readme.txt<br />C:\\zipme\\subdir2\\<br />C:\\zipme\\subdir2\\readme.txt<br /><br />I get the following exception when calling Save(\"C:\\zipme\\\") on the ZipFile instance.<br /><br />System.IndexOutOfRangeException: Index was outside the bounds of the array.<br />at Ionic.Utils.Zip.ZipEntry.WriteHeader(Stream s, Byte[] bytes) in C:\\SourceCode\\Branches\\MCC MLMv2\\Library Projects\\Ionic.Utils.Zip\\ZipEntry.cs:line 852<br />   at Ionic.Utils.Zip.ZipEntry.Write(Stream s) in C:\\SourceCode\\Branches\\MCC MLMv2\\Library Projects\\Ionic.Utils.Zip\\ZipEntry.cs:line 928<br />   at Ionic.Utils.Zip.ZipFile.Save() in C:\\SourceCode\\Branches\\MCC MLMv2\\Library Projects\\Ionic.Utils.Zip\\ZipFile.cs:line 739<br /><br />But if I include an actual file at the root level:<br /><br /><b>C:\\zipme\\junkfile.txt</b><br />C:\\zipme\\subdir1\\<br />C:\\zipme\\subdir1\\readme.txt<br />C:\\zipme\\subdir2\\<br />C:\\zipme\\subdir2\\readme.txt<br /><br />everything works fine. What am I missing?<br />",
    "PostedDate": "2008-03-26T09:33:33.087-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "84823",
    "ThreadId": "24764",
    "Html": "\r\nwow!  That stinks.   Let me check it out.<br />",
    "PostedDate": "2008-04-03T10:38:51.89-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "84857",
    "ThreadId": "24764",
    "Html": "\r\nHold on now, when you call zip.Save(\"c:\\zipme\\\") , you are passing in a directory name, yes? <br /><br />That is incorrect usage. I guess the Save(string) method should check.  But you must specify a filename, not a directory name, when calling that Save() method.  Try that ?<br /><br />Or maybe you are specifying a real filename.  I don't know for sure.  When I tried this, it worked for me. <br /><br />If you think you are using it correctly, can you send me a short test case?  It should be about 30 lines of code.  I just added some unit tests to the DotNetZip solution (not yet released here), and in the test that covers an empty root directory, it just works.<br /><br /><pre style=\"background-color:#ECECEC; border:dashed .1em #3E62A6; font-family:Consolas, Courier New, Courier, Monospace; font-size:1em; margin-top:0; padding:.5em; height:auto; overflow:auto; overflow-x:auto; overflow-y:auto;\">\r\n        [TestMethod]\r\n        public void ZipDirectoryWithEmptyRoot()\r\n        {\r\n            int i, j;\r\n            int entries = 0;\r\n \r\n            string currentDir = System.IO.Directory.GetCurrentDirectory();\r\n \r\n            string TopLevelDir = GenerateUniqueFilename(\"tmp\");\r\n            System.IO.Directory.CreateDirectory(TopLevelDir);\r\n            _FilesToRemove.Add(TopLevelDir);\r\n \r\n            int subdirCount = _rnd.Next(2) + 2;\r\n            for (i = 0; i &lt; subdirCount; i++)\r\n            {\r\n                string Subdir = GenerateUniqueFilename(\"tmp\", TopLevelDir);\r\n                System.IO.Directory.CreateDirectory(Subdir);\r\n \r\n                int fileCount = _rnd.Next(2) + 2;\r\n                for (j = 0; j &lt; fileCount; j++)\r\n                {\r\n                    CreateUniqueFile(\"bin\", Subdir, _rnd.Next(10000) + 5000);\r\n                    entries++; \r\n                }\r\n            }\r\n \r\n            string ZipFileToCreate = GenerateUniqueFilename(\"zip\");\r\n            _FilesToRemove.Add(ZipFileToCreate);\r\n \r\n            Assert.IsFalse(System.IO.File.Exists(ZipFileToCreate), \"The temporary zip file '{0}' already exists.\", ZipFileToCreate);\r\n \r\n            System.IO.Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(TopLevelDir));\r\n            string RelativeDir = System.IO.Path.GetFileName(TopLevelDir);\r\n \r\n            using (ZipFile zip = new ZipFile(ZipFileToCreate))\r\n            {\r\n                zip.AddDirectory(RelativeDir);\r\n                zip.Save();\r\n            }\r\n            System.IO.Directory.SetCurrentDirectory(currentDir);\r\n \r\n \r\n            Assert.IsTrue(CheckZip(ZipFileToCreate, entries),\r\n                    \"Zip file created seems to be invalid.\");\r\n \r\n        }\r\n</pre>",
    "PostedDate": "2008-04-03T12:40:02.283-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "87791",
    "ThreadId": "24764",
    "Html": "\r\nThis discussion has been copied to a work item. Click here to <a href=\"http://www.codeplex.com/DotNetZip/WorkItem/View.aspx?WorkItemId=4421\">go to the work item and continue the discussion</a>.<br />",
    "PostedDate": "2008-04-19T12:21:42.373-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]