%@ LANGUAGE = VBScript %> <% Option Explicit %> <% ' ------------------------------------------------------- ' ASP DotNetZip Example ' ------------------------------------------------------- ' This example ASP page uses DotNetZip (Ionic.Zip.dll) via COM ' interop. The page opens a zip file, then allows the user ' to download any individual file within the zip file. ' '' To get this to work, you must be sure to register DotNetZip for COM '' interop (regasm). Also you need to be sure that IIS/ASP has the correct '' permissions to instantiate the ZipFile object. In my experience I Was '' able to do this by copying Ionic.Zip.dll to the '' c:\windows\system32\inetsrv directory, then calling "regasm /codebbase '' Ionic.Zip.dll" from within that directory. '' This example assumes that the ASP page is deployed into a directory, '' that contains a subdirectory called "fodder". Fodder must be readable, '' and should contain one or more zip files. This page allows the user to '' select a zip file, then select a file within the zip file, and download '' that file. '' '' If Request.Form("Submit") = "Download" Then dim pathForZipFile, fileToDownload pathForZipFile= Request.Form("zipFile") if pathForZipFile <> "" Then fileToDownload = Request.Form("fileToDownload") Response.Clear Response.AddHeader "Content-Disposition", "attachment; filename=" & fileToDownload Response.ContentType = "application/octet-stream" pathForZipFile = Server.MapPath("fodder\" & pathForZipFile) dim zip, ms set zip = Server.CreateObject("Ionic.Zip.ZipFile") zip.Initialize(pathForZipFile) set ms = Server.CreateObject("System.IO.MemoryStream") dim selectedEntry, entry For Each entry in zip If entry.FileName = fileToDownload Then set selectedEntry = entry End If Next selectedEntry.Extract_3(ms) zip.Dispose dim fred fred = ms.ToArray Response.BinaryWrite(fred) ms.Dispose End If Else %>
This page shows how to use DotNetZip from an ASP (Classic) page. This page reads zip files and allows the browser to download items from the zip files.
<% End If %>