[
  {
    "Id": "138941",
    "ThreadId": "41870",
    "Html": "Hi, I am having trouble getting the library to create a valid zip file.<br>\r\nI am working in vb.net in an aspx partial class code page behind. I have pretty much just copied your exmple code and made only minor modification to the output location of the zipfile to use server.Mappath. I get no error reported by the library at runtime. The zip file is actually created in the specified location, but when I try to open it(i have tried in windows explorer, freecommander and with 7zip) I get the following errors:<br>\r\n<br>\r\nerror 11002 - Zip file could not be opened<br>\r\nerror 11036 - The archive is not a valid Zip archive<br>\r\n<br>\r\nI can't immediately see that I am doing anything wrong in the code, is this a bug in the library or can you see something that I have missed.<br>\r\n<br>\r\nThanks<br>\r\n<br>\r\n<br>\r\n<span style=\"font-size:13px\">\r\n<p>&nbsp;</p>\r\n</span>\r\n<p><span style=\"font-size:13px;color:#0000ff\">Function</span><span style=\"font-size:13px\"> doZip() </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">String\r\n<p>&nbsp;</p>\r\n</span></p>\r\n<span style=\"font-size:13px\">\r\n<p>&nbsp;</p>\r\n</span>\r\n<p><span style=\"font-size:13px;color:#0000ff\">Dim</span><span style=\"font-size:13px\"> sourceDir </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">String</span><span style=\"font-size:13px\"> = Server.Mappath(</span><span style=\"font-size:13px;color:#a31515\">&quot;.\\templates\\temp\\&quot;</span><span style=\"font-size:13px\">)\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n</span></p>\r\n<p><span style=\"font-size:13px;color:#0000ff\">Dim</span><span style=\"font-size:13px\"> targetName </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">String</span><span style=\"font-size:13px\"> = sourceDir &amp; </span><span style=\"font-size:13px;color:#a31515\">&quot;myzip.zip&quot;\r\n<p>&nbsp;</p>\r\n</span></p>\r\n<span style=\"font-size:13px\">\r\n<p>&nbsp;</p>\r\n</span>\r\n<p><span style=\"font-size:13px;color:#0000ff\">Dim</span><span style=\"font-size:13px\"> ErrorText </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">String</span><span style=\"font-size:13px\"> = </span><span style=\"font-size:13px;color:#a31515\">&quot;OK&quot;\r\n<p>&nbsp;</p>\r\n</span></p>\r\n<span style=\"font-size:13px\">\r\n<p>&nbsp;</p>\r\n</span>\r\n<p><span style=\"font-size:13px;color:#0000ff\">Try\r\n<p>&nbsp;</p>\r\n</span></p>\r\n<span style=\"font-size:13px\">\r\n<p>&nbsp;</p>\r\n</span>\r\n<p><span style=\"font-size:13px;color:#0000ff\">Using</span><span style=\"font-size:13px\"> zip </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> ZipFile = </span><span style=\"font-size:13px;color:#0000ff\">New</span><span style=\"font-size:13px\"> ZipFile(targetName)\r\n<p>&nbsp;</p>\r\n<p>zip.AddFileFromString(</p>\r\n</span></p>\r\n<p><span style=\"font-size:13px;color:#a31515\">&quot;Readme.txt&quot;</span><span style=\"font-size:13px\">, </span><span style=\"font-size:13px;color:#a31515\">&quot;&quot;</span><span style=\"font-size:13px\">, </span><span style=\"font-size:13px;color:#a31515\">&quot;Test text&quot;</span><span style=\"font-size:13px\">)\r\n<p>&nbsp;</p>\r\n<p>zip.Save()</p>\r\n<p>&nbsp;</p>\r\n</span></p>\r\n<p><span style=\"font-size:13px;color:#0000ff\">End</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">Using\r\n<p>&nbsp;</p>\r\n</span></p>\r\n<span style=\"font-size:13px\">\r\n<p>&nbsp;</p>\r\n</span>\r\n<p><span style=\"font-size:13px;color:#0000ff\">Catch</span><span style=\"font-size:13px\"> ex1 </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> Exception\r\n<p>&nbsp;</p>\r\n<p>ErrorText = ex1.ToString()</p>\r\n<p>&nbsp;</p>\r\n</span></p>\r\n<p><span style=\"font-size:13px;color:#0000ff\">End</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">Try\r\n<p>&nbsp;</p>\r\n</span></p>\r\n<span style=\"font-size:13px\">\r\n<p>&nbsp;</p>\r\n</span>\r\n<p><span style=\"font-size:13px;color:#0000ff\">Return</span><span style=\"font-size:13px\"> ErrorText\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n</span></p>\r\n<p><span style=\"font-size:13px;color:#0000ff\">End</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">Function\r\n<p>&nbsp;</p>\r\n</span></p>\r\n",
    "PostedDate": "2008-12-09T07:03:22.723-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "138948",
    "ThreadId": "41870",
    "Html": "I had this problem when I first started. When creating a zip file, I found it best to do something like this:<br>\r\n<br>\r\n<p><span style=\"font-size:13px;color:rgb(0, 0, 255)\">Using</span><span style=\"font-size:13px\"> zip </span><span style=\"font-size:13px;color:rgb(0, 0, 255)\">As</span><span style=\"font-size:13px\"> ZipFile = </span><span style=\"font-size:13px;color:rgb(0, 0, 255)\">New</span><span style=\"font-size:13px\"> ZipFile()\r\n<p>&nbsp;zip.AddFileFromString(<span style=\"font-size:13px;color:rgb(163, 21, 21)\">&quot;Readme.txt&quot;</span><span style=\"font-size:13px\">, </span><span style=\"font-size:13px;color:rgb(163, 21, 21)\">&quot;&quot;</span><span style=\"font-size:13px\">, </span><span style=\"font-size:13px;color:rgb(163, 21, 21)\">&quot;Test text&quot;</span><span style=\"font-size:13px\">)\r\n<p>&nbsp;zip.Save(<span style=\"font-size:13px\">targetName</span>)</p>\r\n<p>&nbsp;<span style=\"font-size:13px;color:rgb(0, 0, 255)\">End</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:rgb(0, 0, 255)\">Using\r\n</span></p>\r\n</span></p>\r\n</span></p>\r\n",
    "PostedDate": "2008-12-09T07:14:07.64-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "138952",
    "ThreadId": "41870",
    "Html": "Hi John,<br>\r\n             Thanks for your quick reply. <br>\r\n<br>\r\nI have tried putting the targetname in the zip.save method instead of the constructor as you suggested, but the result is the same. I still get an invalid zip file.\r\n",
    "PostedDate": "2008-12-09T07:22:03.673-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "138964",
    "ThreadId": "41870",
    "Html": "ok, this is curious. I have just found that I can get a valid zip if I write it out to the Response.Output stream, but not when writing to a file.<br>\r\nDoes this throw any light on the problem? I'd much rather have it write to the filesystem.<br>\r\n<br>\r\nThanks\r\n",
    "PostedDate": "2008-12-09T07:59:08.843-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "138983",
    "ThreadId": "41870",
    "Html": "<p>I think I have found a workaround so am posting in-case anyone else gets the same problem.<br>\r\n<br>\r\nWhen using the string constructor I got an invalid zip created. This looks to me like it must be a bug in the library.<br>\r\nIt looks like the stream constructor works ok, so I modified the code to pass in a filestream like so:<br>\r\n<span style=\"font-size:13px\">\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n</span></p>\r\n<p><span style=\"font-size:13px;color:#0000ff\">Dim</span><span style=\"font-size:13px\"> fs </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> FileStream = File.Create(targetName)</span><span style=\"font-size:13px\">\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n</span></p>\r\n<p><span style=\"font-size:13px;color:#0000ff\">Using</span><span style=\"font-size:13px\"> zip </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> ZipFile = </span><span style=\"font-size:13px;color:#0000ff\">New</span><span style=\"font-size:13px\"> ZipFile(fs)<br>\r\n<br>\r\nand it looks to produce a valid zip now.\r\n<p>&nbsp;</p>\r\n</span></p>\r\n",
    "PostedDate": "2008-12-09T08:26:20.547-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "138989",
    "ThreadId": "41870",
    "Html": "It might be a permissions problem. My project for which I use this library is a winforms app and I know asp.net can throw some strange permissions into the mix.<br>\r\n<br>\r\nI guess the important thing is that it works. Yeah!<br>\r\n",
    "PostedDate": "2008-12-09T08:40:32.58-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "138994",
    "ThreadId": "41870",
    "Html": "Thanks John, I think you might be right. It might also be made worse because I'm running Vista as well and everything takes about 3 clicks to approve.<br>\r\n It's just security gone mad!!<br>\r\n<br>\r\nCheers\r\n",
    "PostedDate": "2008-12-09T08:49:25.387-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]