This project is read-only.

Specific files to zip in code

Jun 8, 2010 at 8:45 PM
Edited Jun 8, 2010 at 8:45 PM
I've been trying to specify specific files to zip directly in my code, as opposed to having to select from a list. Basically the end goal is that users will click on an item to download, the script then needs to take the appropriate file and zip that file and a copy of PDF file and provide that to the user. So to begin I wanted to see if I can specify a specific file in the code, but I'm getting the following error: System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Collections.Generic.IEnumerable`1[System.String]'. I feel really dumb with this one as I know its going to be something simple. Here's my code: [CODE] Imports System.Text Imports System.IO Imports Ionic.Zip Partial Class b2_ShanesTest Inherits System.Web.UI.Page Public Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Response.Clear() Response.BufferOutput = False 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) Dim fileName As String = "d:\inetpub\wwwroot\cadownloadcentre\b2\CAlogo\CA_Brand_Guide.pdf" Using zip As New ZipFile() zip.AddFiles(fileName) zip.Save(Response.OutputStream) End Using Response.Close() End Sub End Class [/CODE]
Jun 10, 2010 at 4:34 PM
Never mind, I figured out my issue. After taking a few days to think about this and clear my head, I finally read the help file and found the answer. Shane