The entry name must be non-null and non-empty

Mar 5, 2010 at 2:14 PM
Edited Mar 5, 2010 at 2:20 PM

I've searched for this error, but couldn't find anything relevant.

 

I'm building a page with some files that when their checkboxes are selected, they'll get zipped in a file.

Apparently it's working, but only for the 1st time. I mean, if I load the page again, after the 1st time I try to zip some files, I get the following error:

 

 

The entry name must be non-null and non-empty. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Ionic.Zip.ZipException: The entry name must be non-null and non-empty.

Source Error:
Line 36:        
Line 37: Using zip As New ZipFile()
Line 38: zip.AddFiles(vectorfic, "")
Line 39:
Line 40: zip.Save(Response.OutputStream)

Stack Trace: [ZipException: The entry name must be non-null and non-empty.] Ionic.Zip.ZipEntry.Create(String filename, String nameInArchive, Boolean isStream, Stream stream) in C:\dinoch\dev\dotnet\zip\DotNetZip\Zip Partial DLL\ZipEntry.cs:2520 Ionic.Zip.ZipEntry.Create(String filename, String nameInArchive) in C:\dinoch\dev\dotnet\zip\DotNetZip\Zip Partial DLL\ZipEntry.cs:2513 Ionic.Zip.ZipFile.AddFile(String fileName, String directoryPathInArchive) in C:\dinoch\dev\dotnet\zip\DotNetZip\Zip Partial DLL\ZipFile.cs:2577 Ionic.Zip.ZipFile.AddFiles(IEnumerable`1 fileNames, Boolean preserveDirHierarchy, String directoryPathInArchive) in C:\dinoch\dev\dotnet\zip\DotNetZip\Zip Partial DLL\ZipFile.cs:2843 Ionic.Zip.ZipFile.AddFiles(IEnumerable`1 fileNames, String directoryPathInArchive) in C:\dinoch\dev\dotnet\zip\DotNetZip\Zip Partial DLL\ZipFile.cs:2772 ASP._2_aspx.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\2.aspx:38 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +50 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

 

This is my code:

 

 

<script language="VB" runat="server">


	Sub Page_Load(sender As Object, e As EventArgs)
	    Dim vectorfic as New System.Collections.Generic.List(Of String)()
        chkbox.Text = ""
		If Not(Request.Form("multiple") Is Nothing) Then		
            chkbox.Text = Request.Form("multiple")
            'Response.Write(chkbox.Text & "<br>")						
        End If
        vectorfic.AddRange(Split(chkbox.Text, ",")

Dim archiveName As String = String.Format("archive-{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss")) Response.ContentType = "application/zip" Response.AddHeader("content-disposition", "filename=" + archiveName) Using zip As New ZipFile() zip.AddFiles(vectorfic, "") zip.Save(Response.OutputStream) End Using End Sub </script> <html> <head>  </head> <body> <form runat="server"> <h2>Some sample checkbox form elements:</h2> Multiple HTML Checkboxs With The Same Name: <input id="Checkbox1" name="multiple" value="C:\Inetpub\wwwroot\fic1.txt" type="checkbox" /> <input id="Checkbox2" name="multiple" value="C:\Inetpub\wwwroot\fic2.txt" type="checkbox" /> <input id="Checkbox3" name="multiple" value="C:\Inetpub\wwwroot\fic3.txt" type="checkbox" /> <br /> <br /> <input type="submit" /> <strong><asp:label id="chkbox" runat="server" /></strong>

 

 

Is this because of something not closed, what do you think is missing ?

Thanks in advance

Source Error:

Line 36:        
Line 37: Using zip As New ZipFile()
Line 38: zip.AddFiles(vectorfic, "")
Line 39:
Line 40: zip.Save(Response.OutputStream)
Coordinator
Mar 6, 2010 at 12:26 AM

The "non-null and non empty" error means that you're trying to add a file that has either a null value or "" as the filename.

Check the value of vectorfic before the call to AddFiles().  I expect that you will find that one of the values in the list is either empty or null.