{
  "WorkItem": {
    "AffectedComponent": {
      "Name": "",
      "DisplayName": ""
    },
    "ClosedComment": "",
    "ClosedDate": null,
    "CommentCount": 0,
    "Custom": null,
    "Description": "The file is created and the size seems to be ok, but when I double click it is says its format is wrong or the file is damaged.\n \nThis is the code I'm using \n public MemoryStream CompressFiles(Dictionary<string, MemoryStream> filesToBeCompressed)\n        {\n            var output = new MemoryStream();\n            using (var zip = new ZipFile())\n            {\n                foreach (var entry in filesToBeCompressed)\n                {\n                    entry.Value.Seek(0, SeekOrigin.Begin); // <-- must do this after writing the stream (I've read this in a blog\n                    zip.AddEntry(entry.Key.Substring(entry.Key.LastIndexOf('/') + 1, entry.Key.Length - entry.Key.LastIndexOf('/') - 1), entry.Value);\n                    zip.Save(output);\n                }\n            }\n            return output;\n        }\n \nThen in the calling method\n \n            SaveStreamToFile(documentCompressedName,getDocument());\n \n            getDocument() calls Compress internally\n \nAnd that method finally\n \nprivate static void SaveStreamToFile(string fileFullPath, Stream stream)\n        {\n            if (stream.Length == 0) return;\n \n            // Create a FileStream object to write a stream to a file\n            using (FileStream fileStream = System.IO.File.Create(fileFullPath, (int)stream.Length))\n            {\n                // Fill the bytes[] array with the stream data\n                var bytesInStream = new byte[stream.Length];\n                stream.Read(bytesInStream, 0, (int)bytesInStream.Length);\n \n                // Use FileStream object to write to the specified file\n                fileStream.Write(bytesInStream, 0, bytesInStream.Length);\n            }\n        }",
    "LastUpdatedDate": "2013-02-21T18:43:00.767-08:00",
    "PlannedForRelease": "",
    "ReleaseVisibleToPublic": false,
    "Priority": {
      "Name": "Low",
      "Severity": 50,
      "Id": 1
    },
    "ProjectName": "DotNetZip",
    "ReportedDate": "2011-10-05T11:24:00.997-07:00",
    "Status": {
      "Name": "Proposed",
      "Id": 1
    },
    "ReasonClosed": {
      "Name": "Unassigned"
    },
    "Summary": "Corrupted file while compressing stream",
    "Type": {
      "Name": "Issue",
      "Id": 3
    },
    "VoteCount": 2,
    "Id": 14330
  },
  "FileAttachments": [],
  "Comments": [
    {
      "Message": "The problem was that I needed to write this in the last method:\r\n// Set the position within the stream to the beginning of the stream\r\n  stream.Seek(0, SeekOrigin.Begin);      \r\n\r\nYou can check the answer here: http://stackoverflow.com/questions/7665989/corrupted-file-while-compressing-stream-using-dotnetzip-library\r\nApologies for opening a bug issue here.",
      "PostedDate": "2011-10-05T12:38:03.37-07:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2011-11-18T01:05:08.113-08:00",
      "Id": -2147483648
    },
    {
      "Message": "",
      "PostedDate": "2013-02-21T18:43:00.767-08:00",
      "Id": -2147483648
    }
  ]
}