[
  {
    "Id": "237044",
    "ThreadId": "69638",
    "Html": "<p>I can create a zip file if I hard code the file path.</p>\r\n<p>Zip.AddFile(C:\\filename.pdf&quot;, &quot;&quot;)<br>Zip.AddFile(&quot;C:\\Test.txt&quot;, &quot;&quot;)<br>Zip.Save(Response.OutputStream)</p>\r\n<p>This works!&nbsp;</p>\r\n<p>If I place the same values into a file array, it fails</p>\r\n<p>filenames = fileList.ToArray()<br>Zip.AddFile(filenames(0), &quot;&quot;)<br>Zip.AddFile(filenames(1), &quot;&quot;)<br>Zip.Save(Response.OutputStream)</p>\r\n<p>I have my file name and path stored in a database.&nbsp; I need to read the file name and path and create a zip file to be downloaded.</p>\r\n<p>Yes, the values are the same in the filenames array.&nbsp;</p>\r\n<p>What am I doing wrong?</p>\r\n<p>I have trying reading the file into a memorystream.&nbsp; It works if the path is hard codes, but once I use variables the zip file is damaged.&nbsp; It says the file name are too long.&nbsp; I can open it, but each file name has .... at the end.&nbsp; Again, if I put the hard code the file path everything is ok.&nbsp;</p>\r\n<p>The files are stored on a network share.&nbsp; I have full permission.&nbsp; Everything works ok if I hard code the path (type it in).&nbsp; If I use variables, the zip file is damaged and can not view it.&nbsp; It has to be something with how my variables are defined.&nbsp; I have tried Lists, arrays, reading from a database and any other method I could find or think of.&nbsp;</p>",
    "PostedDate": "2009-09-21T13:59:17-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "237155",
    "ThreadId": "69638",
    "Html": "<p>I suggest you employ:</p>\r\n<ul>\r\n<li>a using clause.&nbsp; Follow the examples in the doc. </li>\r\n<li>a try...catch clause.&nbsp; If the zip file is damaged there is likely an exception occurring. Maybe you're missing it. </li>\r\n<li>a call Response.Close().&nbsp; </li>\r\n</ul>\r\n<p>You may be including these things but you don't show them.</p>\r\n<p>I don't know what this means:&nbsp; &quot;It says the file name are too long.&nbsp; I can open it, but each file name has .... at the end.&quot;&nbsp;&nbsp; How do you view the value of the filename to see the ... ?&nbsp; What tool are you using to view the file name, and what exactly is the &quot;file name&quot; in this case - a string variable in your program?&nbsp; A property on the ZipFile object?&nbsp; something else?</p>\r\n<p>I can't imagine the problem but I think maybe the variables do not hold the values you think they do.&nbsp; There's an assumption you are making which seems safe and correct but isn't.&nbsp;&nbsp;&nbsp;Do you know how to run your app in the debugger?&nbsp; Maybe check the value of the filenames(0) and filenames(1) things, in the debugger, during a run.</p>\r\n<p>Good luck!</p>",
    "PostedDate": "2009-09-21T23:49:45.67-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "237289",
    "ThreadId": "69638",
    "Html": "<p>The problem seems to happen with with UNC paths (not local).&nbsp;&nbsp; If I use a local path C:\\ instead of <a>\\\\server\\share</a> it works with variables.&nbsp;</p>\r\n<p>With <a>\\\\server\\share</a> in a foreach loop with variables.&nbsp; I am getting the path from a database.&nbsp; If I hard code the <a>\\\\server\\share</a> it works correctly.&nbsp; I have stepped through the code with debugger and verfied the paths by copy and pasting the values into windows explorer.&nbsp; I know it is correct.</p>\r\n<p>here is one of the for each statements it is failing on:</p>\r\n<p>Using ZIp As New ZipFile</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HttpContext.Current.Response.Clear()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HttpContext.Current.Response.BufferOutput = False<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HttpContext.Current.Response.ContentType = &quot;application/zip&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HttpContext.Current.Response.AddHeader(&quot;content-disposition&quot;, &quot;attachment; filename=&quot; + archiveName)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Using dataReader As IDataReader = db.ExecuteReader(command)</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;While (dataReader.Read())&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Zip.AddFile(dataReader(&quot;FileDirectory&quot;) + &quot;\\&quot; + dataReader(&quot;FileName&quot;), &quot;&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End While<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ZIp.Save(HttpContext.Current.Response.OutputStream)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End Using<br>End Using</p>\r\n<p>I am using winrar to view the archieve.&nbsp; It also fails with Windows XP built in zip handler.&nbsp;</p>\r\n<p>Winrar results:<br>The zip is the correct size.&nbsp; The files inside the zip show the correct size, but the Type shows &quot;File ???&quot;&nbsp; The filename should be 0_3boxes.jpg, but it shows it as 0_3boxes.jpg ...</p>\r\n<p>Windows XP Zip Handler:<br>The compressed (zipped) Folder is invalid or corrupt.</p>\r\n<p>The problem does not exist if I use a local path in the database.&nbsp; I think maybe the files are not being copied or the operation is timing out before the files are completely copied.&nbsp;</p>",
    "PostedDate": "2009-09-22T06:10:39.987-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "237297",
    "ThreadId": "69638",
    "Html": "<p>If the files did not exist, the zip class would through an exception.</p>",
    "PostedDate": "2009-09-22T06:20:55.54-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "237300",
    "ThreadId": "69638",
    "Html": "<p>That why you need breaks when you code.&nbsp; The database variable had an extra 100 spaces in it.&nbsp; A simple trim() statement fixed that.&nbsp;</p>",
    "PostedDate": "2009-09-22T06:32:52.553-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "237338",
    "ThreadId": "69638",
    "Html": "<p>Great, glad you found it.</p>\r\n<p>I'm trying to decide whether DotNetZip should do the Trim() for you or not.&nbsp; At this point I'm not sure.&nbsp; A filename on Windows cannot end with a space.&nbsp; I'm going to think about this a little.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-09-22T07:53:39.397-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "237339",
    "ThreadId": "69638",
    "Html": "This discussion has been copied to a work item. Click <a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=8824\">here</a> to go to the work item and continue the discussion.",
    "PostedDate": "2009-09-22T07:55:07.117-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "237380",
    "ThreadId": "69638",
    "Html": "<p>I was joining strings together to form a path.&nbsp;&nbsp; filepath + &quot;\\&quot; + filename.&nbsp;&nbsp; I needed to trim the filepath and filename variables.&nbsp; It should be left to the user of the library to trim the strings.</p>\r\n<p>Thanks for your great work on the library and your help.</p>",
    "PostedDate": "2009-09-22T08:53:18.32-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]