[
  {
    "Id": "221334",
    "ThreadId": "64990",
    "Html": "<p>Hi,</p>\r\n<p>I'm having trouble adding files to Zip in a ASP.Net web application. Running Vista, VS2008, Iconic.Zip.dll 1.8.4.16. I suspect it's something obvious that I'm missing.</p>\r\n<p>The application is running with specific domain account for the application pool. The account has read/write access to the&nbsp;source files folder and c:\\temp folder. I tried using the&nbsp;<span style=\"font-size:x-small\">TempFileFolder=&quot;c:\\temp&quot; but have&nbsp;a simliar&nbsp;issue (complains it can't find the&nbsp;c:\\temp folder)&nbsp;</span></p>\r\n<p><span style=\"font-size:x-small\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color:Green\">'build the zip </span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color:Blue\">Dim</span> zip <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">New</span> ZipFile<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color:Blue\">If</span> Request.QueryString(<span style=\"color:#A31515\">&quot;f&quot;</span>) = <span style=\"color:#A31515\">&quot;All&quot;</span> <span style=\"color:Blue\">Then</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color:Green\">'do explicit search for .inv files, if we use &quot;*.inv&quot; in getfiles() we also get &quot;*.inv_txf&quot; etc</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color:Blue\">Dim</span> invFiles <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">New</span> List(Of <span style=\"color:Blue\">String</span>)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color:Blue\">Dim</span> invfile <span style=\"color:Blue\">As</span> FileInfo<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color:Blue\">For</span> <span style=\"color:Blue\">Each</span> invfile <span style=\"color:Blue\">In</span> diDlink.GetFiles()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color:Green\">'only add the inv files</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color:Blue\">If</span> invfile.Extension = <span style=\"color:#A31515\">&quot;.inv&quot;</span> <span style=\"color:Blue\">Then</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; invFiles.Add(invfile.FullName)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">If</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color:Blue\">Next</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color:Green\">'don't use the path of the source file in the Zip</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip.AddFiles(invFiles, <span style=\"color:#A31515\">&quot;&quot;</span>)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color:Blue\">Else</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color:Green\">'build a zip for a single file</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip.AddFile(dlinkDirectory &amp; dlinkFile, <span style=\"color:#A31515\">&quot;&quot;</span>)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">If</span><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"color:Green\">'download to customer</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.ContentType = <span style=\"color:#A31515\">&quot;application/octet_stream&quot;</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.AddHeader(<span style=\"color:#A31515\">&quot;content-disposition&quot;</span>, <span style=\"color:#A31515\">&quot;attachment; filename=&quot;</span> &amp; zipFilename)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip.Save(Context.Response.OutputStream)<br><br></span></p>\r\n<p><span style=\"font-size:x-small\">\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.\r\n\r\nSource Error: \r\n\r\n\r\nLine 45:         Else\r\nLine 46:             'build a zip for a single file\r\nLine 47:             zip.AddFile(dlinkDirectory &amp; dlinkFile, &quot;&quot;)\r\nLine 48:         End If\r\nLine 49: \r\n \r\n\r\nSource File: C:\\Users\\Colin.DANKSNET\\Net\\Web\\Internet\\AxWeb\\Customer\\eCommerce\\DownloadDlinkInvoice.aspx.vb    Line: 47 \r\n\r\nStack Trace: \r\n\r\n\r\n[SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]\r\n   System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark&amp; stackMark, Boolean isPermSet) +0\r\n   System.Security.CodeAccessPermission.Demand() +58\r\n   System.IO.File.GetLastWriteTimeUtc(String path) +114\r\n   Ionic.Zip.ZipEntry.Create(String filename, String nameInArchive, Boolean isStream, Stream stream) +357\r\n   Ionic.Zip.ZipEntry.Create(String filename, String nameInArchive) +41\r\n   Ionic.Zip.ZipFile.AddFile(String fileName, String directoryPathInArchive) +68\r\n   eCommerce_DownloadDlinkInvoice.Page_Load(Object sender, EventArgs e) in C:\\Users\\Colin.DANKSNET\\Net\\Web\\Internet\\AxWeb\\Customer\\eCommerce\\DownloadDlinkInvoice.aspx.vb:47\r\n   System.Web.UI.Control.OnLoad(EventArgs e) +99\r\n   System.Web.UI.Control.LoadRecursive() +50\r\n   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785\r\n   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242\r\n   System.Web.UI.Page.ProcessRequest() +80\r\n   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21\r\n   System.Web.UI.Page.ProcessRequest(HttpContext context) +49\r\n   ASP.ecommerce_downloaddlinkinvoice_aspx.ProcessRequest(HttpContext context) +37\r\n   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181\r\n   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +75\r\n\r\n</pre>\r\n<pre>what am I missing?</pre>\r\n<pre>Thanx Colin... \r\n\r\n</pre>\r\n</div>\r\n</span></p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-08-09T16:06:15.97-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "221393",
    "ThreadId": "64990",
    "Html": "<p>Colin, it seems like your ASPNET application is not able to READ the file being added to the ZIP.</p>\r\n<p>Whatever&nbsp; &quot;dlinkDirectory &amp; dlinkFile&quot;&nbsp; resolves to, is apparently not accessible to ASPNET.</p>\r\n<p>The error you are seeing has nothing to do with ZipFile.TempFileFolder. ZipFile.TempFileFolder is a good thing to be aware of, when using DotNetZip from within ASPNET. But it isn't relevant when saving directly to a stream, which is what you are doing in this case.</p>\r\n<p>-Cheeso</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-08-09T22:42:10.613-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "221816",
    "ThreadId": "64990",
    "Html": "<pre>Hi Cheeso,</pre>\r\n<pre>I added a line of code (see below) to see if I could read the file into a string. This works OK, no errors. I can see the content of the file in the debugger, so it definetly opened and read the file OK. </pre>\r\n<pre>If I then step to the Zip.AddFile I still get the Security Exception. </pre>\r\n<pre>            'build a zip for a single file\r\n            Dim aaa As String = File.ReadAllText(dlinkDirectory &amp; dlinkFile)\r\n            zip.AddFile(dlinkDirectory &amp; dlinkFile, &quot;&quot;)</pre>\r\n<pre>Is it something to do with Trusting the ionic.zip.dll ? I have set full trust in my web.config file\r\n\r\n</pre>\r\n<pre>Colin...</pre>",
    "PostedDate": "2009-08-10T18:42:29.013-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "221890",
    "ThreadId": "64990",
    "Html": "<table border=0 width=800>\r\n<tbody>\r\n<tr>\r\n<td>\r\n<p>No, I don't think it has to do with trusting Ionic.Zip.dll.&nbsp; The app is failing when it tries to read the last write time of the file in question.&nbsp; Is this a remote file? Is it on a share?</p>\r\n<p>I don't know why DotNetZip is failing to read the LastWriteTime of the file.&nbsp; But a failure there should not be critical.&nbsp; I can modify the library so that it doesn't fail in this case - in other words it handles the exception.&nbsp; But you'd have to test it yourself.</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n</td>\r\n</tr>\r\n</tbody>\r\n</table>",
    "PostedDate": "2009-08-10T23:50:43.757-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "221892",
    "ThreadId": "64990",
    "Html": "This discussion has been copied to a work item. Click <a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=8423\">here</a> to go to the work item and continue the discussion.",
    "PostedDate": "2009-08-10T23:57:57.997-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "221896",
    "ThreadId": "64990",
    "Html": "<p>ok, try the build attached to the workitem:</p>\r\n<p><a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=8423\">http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=8423</a></p>",
    "PostedDate": "2009-08-11T00:07:59.467-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]