[
  {
    "Id": "231867",
    "ThreadId": "68177",
    "Html": "<p>I'm having an issue with the zip files I generate not being able to be read in WinZip, but they are readable in things like the built in Windows compression tool and WinRAR. The issue was raised by a customer who has to use WinZip due to company guidelines so they cannot change this, so I'm wondering if anyone has the same error.</p>\r\n<p>When the file is downloaded I can open the zip file in Winzip and I can see the files in the folder fine, however when I try and extract them I get the Error: &quot;Warning: skipping FILENAME. The compressed size stored in the local header for this file is not the same as the compressed size stored in the central header.&quot;</p>\r\n<p>The code I am using to generate the code is below, as I said it works with other zip programs just not Winzip</p>\r\n<p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><span style=\"color:Blue\">string</span> displayFilename = HttpUtility.UrlPathEncode(zipFileName);\r\nResponse.AddHeader(<span style=\"color:#A31515\">&quot;Content-disposition&quot;</span>, <span style=\"color:#A31515\">&quot;attachment; filename=&quot;</span> + displayFilename);\r\nResponse.ContentType = <span style=\"color:#A31515\">&quot;application/octet-stream&quot;</span>;\r\n\r\nIonic.Zip.ZipFile zipFile = <span style=\"color:Blue\">new</span> Ionic.Zip.ZipFile();\r\n<span style=\"color:Blue\">foreach</span> (<span style=\"color:Blue\">string</span> filePath <span style=\"color:Blue\">in</span> filePaths) {\r\n    zipFile.AddFile(filePath, <span style=\"color:#A31515\">&quot;&quot;</span>);\r\n}\r\nzipFile.Save(Response.OutputStream);\r\n</pre>\r\n</div>\r\n</p>\r\n<p>Thanks</p>",
    "PostedDate": "2009-09-07T09:27:59.227-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "231872",
    "ThreadId": "68177",
    "Html": "This discussion has been copied to a work item. Click <a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=8689\">here</a> to go to the work item and continue the discussion.",
    "PostedDate": "2009-09-07T09:32:33.507-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "231876",
    "ThreadId": "68177",
    "Html": "<p>if it is repeatable, can you upload a zipfile that causes the problem, to <a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=8689\">this workitem</a>?</p>\r\n<p>A small zipfile is better.</p>\r\n<p>Also, can you show me the rest of your code?&nbsp; Do you use a <strong>using </strong>statement?&nbsp; If not why not?&nbsp; Where do you call <strong>Close()</strong> on the ZipFile object?</p>\r\n<p>Can you try it with a using statement and let me know if the problem persists?</p>",
    "PostedDate": "2009-09-07T09:35:27.5-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "231882",
    "ThreadId": "68177",
    "Html": "<p>Hi,</p>\r\n<p>Yes it is repeatable, however I can't upload a file at the moment as the data is confidential, I'll try and reproduce the error using some dummy data. The issue appears to happen when the files in the zip file are within a directory, for example:</p>\r\n<p>Folder\\test.txt - Causes an error</p>\r\n<p>test.txt - Doesn't cause an error</p>\r\n<p>No I'm not calling close() on the ZipFile object as there isn't a method in the API to call there, should I be calling close() on the Response.OutputStream after I've called save()?</p>\r\n<p>As for using statement I never use them, I just use the foreach Iterator for the filenames, heres the full method of the code:</p>\r\n<p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><span style=\"color:Gray\">///</span> <span style=\"color:Gray\">&lt;summary&gt;</span>\r\n        <span style=\"color:Gray\">///</span><span style=\"color:Green\"> Puts all the files in the list provided into a zip file, and then streams it to the HTTP Response</span>\r\n        <span style=\"color:Gray\">///</span> <span style=\"color:Gray\">&lt;/summary&gt;</span>\r\n        <span style=\"color:Gray\">///</span> <span style=\"color:Gray\">&lt;param name=&quot;zipFileName&quot;&gt;</span><span style=\"color:Green\">The name of the zip file&lt;/param&gt;</span>\r\n        <span style=\"color:Gray\">///</span> <span style=\"color:Gray\">&lt;param name=&quot;filePaths&quot;&gt;</span><span style=\"color:Green\">A list of absolute file paths&lt;/param&gt;</span>\r\n        <span style=\"color:Blue\">protected</span> <span style=\"color:Blue\">void</span> StreamFilesIntoZipFile(<span style=\"color:Blue\">string</span> zipFileName, List&lt;<span style=\"color:Blue\">string</span>&gt; filePaths) {\r\n            <span style=\"color:Blue\">string</span> displayFilename = HttpUtility.UrlPathEncode(zipFileName);\r\n            Response.AddHeader(<span style=\"color:#A31515\">&quot;Content-disposition&quot;</span>, <span style=\"color:#A31515\">&quot;attachment; filename=&quot;</span> + displayFilename);\r\n            Response.ContentType = <span style=\"color:#A31515\">&quot;application/octet-stream&quot;</span>;\r\n\r\n            Ionic.Zip.ZipFile zipFile = <span style=\"color:Blue\">new</span> Ionic.Zip.ZipFile();\r\n            <span style=\"color:Blue\">foreach</span> (<span style=\"color:Blue\">string</span> filePath <span style=\"color:Blue\">in</span> filePaths) {\r\n                zipFile.AddFile(filePath, <span style=\"color:#A31515\">&quot;&quot;</span>);\r\n            }\r\n            zipFile.Save(Response.OutputStream);\r\n            Response.Close();\r\n        }\r\n</pre>\r\n</div>\r\n</p>",
    "PostedDate": "2009-09-07T09:52:42.66-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "231888",
    "ThreadId": "68177",
    "Html": "<p>Whoops - what I meant was <strong>Dispose()</strong>.&nbsp; you need to call Dispose(), not Close().</p>\r\n<p>The using statement is not optional. Either use it or call ZipFile.Dispose().&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-09-07T10:24:57.517-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]