I'm having trouble adding files to Zip in a ASP.Net web application. Running Vista, VS2008, Iconic.Zip.dll 188.8.131.52. I suspect it's something obvious that I'm missing.
The application is running with specific domain account for the application pool. The account has read/write access to the source files folder and c:\temp folder. I tried using the TempFileFolder="c:\temp"
but have a simliar issue (complains it can't find the c:\temp folder)
'build the zip
As New ZipFile
If Request.QueryString("f") =
'do explicit search for .inv files, if we use "*.inv" in getfiles() we also get "*.inv_txf" etc
Dim invFiles As New List(Of
Dim invfile As FileInfo
For Each invfile
'only add the inv files
If invfile.Extension =
'don't use the path of the source file in the Zip
'build a zip for a single file
zip.AddFile(dlinkDirectory & dlinkFile,
'download to customer
"attachment; filename=" & zipFilename)
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=184.108.40.206, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Line 45: Else
Line 46: 'build a zip for a single file
Line 47: zip.AddFile(dlinkDirectory & dlinkFile, "")
Line 48: End If
Source File: C:\Users\Colin.DANKSNET\Net\Web\Internet\AxWeb\Customer\eCommerce\DownloadDlinkInvoice.aspx.vb Line: 47
[SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=220.127.116.11, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.IO.File.GetLastWriteTimeUtc(String path) +114
Ionic.Zip.ZipEntry.Create(String filename, String nameInArchive, Boolean isStream, Stream stream) +357
Ionic.Zip.ZipEntry.Create(String filename, String nameInArchive) +41
Ionic.Zip.ZipFile.AddFile(String fileName, String directoryPathInArchive) +68
eCommerce_DownloadDlinkInvoice.Page_Load(Object sender, EventArgs e) in C:\Users\Colin.DANKSNET\Net\Web\Internet\AxWeb\Customer\eCommerce\DownloadDlinkInvoice.aspx.vb:47
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.ecommerce_downloaddlinkinvoice_aspx.ProcessRequest(HttpContext context) +37
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
what am I missing?
Aug 10, 2009 at 5:42 AM
Colin, it seems like your ASPNET application is not able to READ the file being added to the ZIP.
Whatever "dlinkDirectory & dlinkFile" resolves to, is apparently not accessible to ASPNET.
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
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.
If I then step to the Zip.AddFile I still get the Security Exception.
'build a zip for a single file
Dim aaa As String = File.ReadAllText(dlinkDirectory & dlinkFile)
zip.AddFile(dlinkDirectory & dlinkFile, "")
Is it something to do with Trusting the ionic.zip.dll ? I have set full trust in my web.config file
Aug 11, 2009 at 6:50 AM
No, I don't think it has to do with trusting Ionic.Zip.dll. The app is failing when it tries to read the last write time of the file in question. Is this a remote file? Is it on a share?
I don't know why DotNetZip is failing to read the LastWriteTime of the file. But a failure there should not be critical. I can modify the library so that it doesn't fail in this case - in other words it handles the exception. But you'd
have to test it yourself.
Aug 11, 2009 at 6:57 AM
This discussion has been copied to a work item. Click
here to go to the work item and continue the discussion.
Aug 11, 2009 at 7:07 AM
ok, try the build attached to the workitem: