{
  "WorkItem": {
    "AffectedComponent": {
      "Name": "",
      "DisplayName": ""
    },
    "ClosedComment": "fixed in changset 33304.  First binary to get this fix&#58; v1.8.3.27. ",
    "ClosedDate": "2009-06-17T13:40:29.687-07:00",
    "CommentCount": 0,
    "Custom": null,
    "Description": "Cheeso,\n \nThanks for the quick reply. I don't believe I made the part about the files in the root very clear. In my tests (just ran them again) the only files I get AT ALL in the archive are the two in the root. The folder structure is gone entirely. Whether \"recursive\" is set to true or false I get the exact same result: test1.txt and test2.txt in the root of the archive and nothing else - no other files - no other folders.\n \nThanks again for any help you can provide.\n \n- Bob",
    "LastUpdatedDate": "2013-05-16T05:32:18.83-07:00",
    "PlannedForRelease": "",
    "ReleaseVisibleToPublic": false,
    "Priority": {
      "Name": "Low",
      "Severity": 50,
      "Id": 1
    },
    "ProjectName": "DotNetZip",
    "ReportedDate": "2009-06-12T04:00:54.123-07:00",
    "Status": {
      "Name": "Closed",
      "Id": 4
    },
    "ReasonClosed": {
      "Name": "Unassigned"
    },
    "Summary": "AddSelectedFiles prefixes subdirs with slash - broken on XP compressed folders - 1.8.3.17",
    "Type": {
      "Name": "Issue",
      "Id": 3
    },
    "VoteCount": 1,
    "Id": 7883
  },
  "FileAttachments": [
    {
      "FileId": 1989,
      "FileName": "BobCheckitout.cs",
      "DownloadUrl": ".\\1989"
    },
    {
      "FileId": 1992,
      "FileName": "BobCheckItOut.zip",
      "DownloadUrl": ".\\1992"
    },
    {
      "FileId": 1993,
      "FileName": "ScreenShot.JPG",
      "DownloadUrl": ".\\1993"
    }
  ],
  "Comments": [
    {
      "Message": "Cheeso, sorry for the delay. I've been moving to a new house. \r\n\r\nI ran your test code and ended up with only two files (Test1.txt, & Test2.txt) which were in the root of the zip. NO folders or other files in archive.",
      "PostedDate": "2009-06-15T14:58:44.95-07:00",
      "Id": -2147483648
    },
    {
      "Message": "Alright, congrats on the new house!  Hmm, the test results are pretty surprising.  Can you post the .zip file produced by that test case?  ",
      "PostedDate": "2009-06-15T17:50:49.353-07:00",
      "Id": -2147483648
    },
    {
      "Message": "Cheeso, here's something really bizarre. The output in the console would make it seem that all 4 files are added to the archive. The .zip, however, only contains the two files. I have attached the screenshot and the resulting .zip file.",
      "PostedDate": "2009-06-16T09:56:47.197-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2009-06-16T09:56:51.167-07:00",
      "Id": -2147483648
    },
    {
      "Message": "...and the screenshot",
      "PostedDate": "2009-06-16T09:58:13.21-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2009-06-16T09:58:14.837-07:00",
      "Id": -2147483648
    },
    {
      "Message": "Bob, that zip file has 4 files in it. \r\n\r\nc:\\>unzip -l \\desktop\\BobCheckItOut.zip\r\nZipfile: \\desktop\\BobCheckItOut.zip\r\n\r\nModified                     Size  Ratio      Packed  pw?      CRC Filename\r\n--------------------------------------------------------------------------------\r\n2009-06-16 09:51:36          1075    55%         483    N A2179F94 Test1.txt\r\n2009-06-16 09:51:36           990    56%         433    N A005C593 Test2.txt\r\n2009-06-16 09:51:36          1273    59%         518    N D40C2201 /folder1/Test3.txt\r\n2009-06-16 09:51:36          1373    58%         572    N 433BD80C /folder2/Test4.txt\r\n--------------------------------------------------------------------------------\r\n                             4711                                  4 files\r\n\r\nI don't know how you concluded that there are only 2 files, but all 4 are there. ",
      "PostedDate": "2009-06-17T07:56:21.927-07:00",
      "Id": -2147483648
    },
    {
      "Message": "Cheeso, I think yo just found the root of the problem. Try unzipping that file with the built in Windows XP functionality. I've tried it on two different machines at work. The extracted result only contains the two files. ",
      "PostedDate": "2009-06-17T09:18:28.96-07:00",
      "Id": -2147483648
    },
    {
      "Message": "Cheeso, I found the exact problem. When the files are recursed, they are added as follows: \r\n\r\nA file in the root will look like \"Test1.txt\". A file in a subfolder will look like \"/folder1/Test2.txt\" (notice the leading \"/\").\r\n\r\nI ran the following lines of code:\r\nzip1.AddDirectory(\"bobtest\\\\folder3\",\"/folder3\");\r\nzip1.AddDirectory(\"bobtest\\\\folder3\",\"folder3\");\r\n\r\nWhen viewed in WinZip both of these produce the same result. However, when viewed in the built-in Windows utility ONLY the second one produces the expected result. The first one doesn't write anything to the archive. When I traced AddSelectedFiles I noticed the same thing - any subfolders end up with a preceding \"/\".\r\n\r\n",
      "PostedDate": "2009-06-17T11:09:59.963-07:00",
      "Id": -2147483648
    },
    {
      "Message": "Cheeso,\r\nHere's a code snippet that fixes the problem. You can definitely find a more elegant way but this works:\r\n\r\n\r\npublic void AddSelectedFiles(String selectionCriteria,\r\n                                     String directoryOnDisk,\r\n                                     String directoryPathInArchive,\r\n                                     bool recurseDirectories)\r\n        {\r\n            if (String.IsNullOrEmpty(directoryOnDisk)) directoryOnDisk= \".\";\r\n            if (Verbose) StatusMessageTextWriter.WriteLine(\"adding selection '{0}' from dir '{1}'...\", selectionCriteria, directoryOnDisk);\r\n            Ionic.FileSelector ff = new Ionic.FileSelector(selectionCriteria);\r\n            var filesToAdd = ff.SelectFiles(directoryOnDisk, recurseDirectories);\r\n            if (Verbose) StatusMessageTextWriter.WriteLine(\"found {0} files...\", filesToAdd.Count);\r\n\r\n            foreach (var f in filesToAdd)\r\n            {\r\n                if (directoryPathInArchive!=null) \r\n                {\r\n                    string dirInArchive = System.IO.Path.GetDirectoryName(f).Replace(directoryOnDisk, directoryPathInArchive);\r\n\r\n                    //MAJOR hack\r\n                    dirInArchive = dirInArchive.Replace(\"\\\\\", \"\");\r\n                    //end MAJOR hack\r\n\r\n                    this.AddFile(f, dirInArchive);\r\n                }\r\n                else\r\n                    this.AddFile(f, null);\r\n            }\r\n        }",
      "PostedDate": "2009-06-17T12:03:45.66-07:00",
      "Id": -2147483648
    },
    {
      "Message": "Yes, sure looks like a bug.  Thanks for your help on this one.",
      "PostedDate": "2009-06-17T12:27:51.76-07:00",
      "Id": -2147483648
    },
    {
      "Message": "I had a test for compatibility with the XP/Vista shell, but it did not unpack zips that were created with AddSelectedFiles(), so it didn't catch this bug.  I added a new test, fixed the bug.  Running through all tests now. ",
      "PostedDate": "2009-06-17T13:23:17.82-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2009-06-17T13:25:56.567-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2009-06-17T13:40:29.687-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2013-02-21T18:44:14.87-08:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2013-05-16T05:32:18.83-07:00",
      "Id": -2147483648
    }
  ]
}