{
  "WorkItem": {
    "AffectedComponent": {
      "Name": "",
      "DisplayName": ""
    },
    "ClosedComment": "Not a bug.  The description of this workitem is not accurate.  It&#39;s not the case that ZipFile fails when the extension is not .zip.  It IS the case that ZipFile fails to read a zero-byte file as a zipfile.  This is what was happening, and this is desired and documented behavior. I&#39;m closing this. ",
    "ClosedDate": "2011-06-17T20:58:51.33-07:00",
    "CommentCount": 0,
    "Custom": null,
    "Description": "using the following code I get an invalid zip file error:\n \nstring tempFile = Path.GetTempFileName();\nusing (ZipFile zip = new ZipFile(tempFile))\n{\n// more here\n}\n \nHowever if I do this instead it works fine:\nstring tempFile = Path.ChangeExtension(Path.GetTempFileName(), \"zip\");\nusing (ZipFile zip = new ZipFile(tempFile))\n{\n// more here\n}\n \nWould be nice to not have to change the extension of the file just to create a temp zip file.\n \nMy use case is that I create the zip as a temp file, then after zipping is complete (these are large files so it can take a while) I move and rename the temp file to it's final destination.",
    "LastUpdatedDate": "2013-05-16T05:31:45.187-07:00",
    "PlannedForRelease": "",
    "ReleaseVisibleToPublic": false,
    "Priority": {
      "Name": "Low",
      "Severity": 50,
      "Id": 1
    },
    "ProjectName": "DotNetZip",
    "ReportedDate": "2010-08-11T10:36:25.02-07:00",
    "Status": {
      "Name": "Closed",
      "Id": 4
    },
    "ReasonClosed": {
      "Name": "Unassigned"
    },
    "Summary": "Zip File creation fails if extension is not .zip",
    "Type": {
      "Name": "Issue",
      "Id": 3
    },
    "VoteCount": 1,
    "Id": 11743
  },
  "FileAttachments": [],
  "Comments": [
    {
      "Message": "Thanks for the bug report. \r\n\r\nThis is not actually a bug in DotNetZip though.  It's a bug in your code.  Path.GetTempFileName() actually creates a file, a zero-length file.  When you call the ZipFile constructor with that file, ZipFile tries to read the file.  It can read no data, so it throws, and tells you that it cannot read zip data.  This is what I would expect to happen, and this is probably what *should* happenn when you try to read a zero-length file as a zip file. \r\n\r\nWhen you append the .zip extension to the result of Path.GetTempFileName(), you are now referring to a file that *does not exist*.  In this case the ZipFile constructor sees that there is no file, and doesn't try to read it.  It just assumes you are telling it what file to use when you eventually call save().  This still seems like the right thing to do, to me. \r\n\r\nIf you want to simply conjure a filename, then you can use Path.GetRandomFileName(), which returns the name of a file that does not exist.  You can then pass it to ZipFile constructor, and everything will work nicely. \r\n\r\nAlso: It may make for clearer code, to use the no-argument constructor, and pass the temporary filename (from Path.GetRandomFileName()) into the Save() call.  \r\n\r\nI'm going to close this workitem as not-a-bug.\r\n",
      "PostedDate": "2011-06-17T20:57:49.637-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2011-06-17T20:58:51.33-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2013-02-21T18:43:27.9-08:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2013-05-16T05:31:45.187-07:00",
      "Id": -2147483648
    }
  ]
}