ce code permet de creer des fichier zip en asp
Source / Exemple :
<%@ Language=VBScript %>
<%
' This ASP script is a sample provided for the Xceed Zip Compression Library.
' It is called by the frmSelect.htm web page file.
' Download the component in trial version :
' http://www.xceedsoft.com/download/ZipCompL/index.htm
' Download the application :
' http://www.xceedsoft.com/cs/results.asp?id=111
Dim xZip ' Will represent an instance of the Xceed Zip object
Dim ResultCode ' Result Code from the Zip method
Dim sFilesChosen ' HTML output string
Dim sRandom ' Random number string
Dim sFilename ' Filename of self-extracting zip file to create on server
Dim sDownloadURL ' The URL where your browser will download the zip file from
Dim Introtext ' The text for the self-extracting zip file's introduction dialog
' Change these constants below for your own sever, and make
' sure the File1.txt, File2.txt and File3.txt files are placed
' in the PATH_FOR_SOURCE_FILES folder. The xcdsfx32.bin
' self-extractor binary file should also be placed in this folder.
Const PATH_FOR_SOURCE_FILES = "D:\InetPub\testwebsite\Send\"
Const PATH_FOR_ZIP_FILE = "D:\InetPub\testwebsite\Send\Zipfiles\"
Const DOWNLOAD_URL = "http://servername/Send/Zipfiles/"
' Instanciate the Xceed Zip object (the xceedzip.dll should be
' installed on the server, of course)
Set xZip = Server.CreateObject("XceedSoftware.XceedZip.4")
' If you are using the free trial version of Xceed Zip, you'll
' need to run the Xceed Zip trial version's setup program on
' the server, otherwise it will complain it is not licensed.
' If you are a registered user, uncomment the following line
' and replace the text in quotes with your license key.
' xZip.License("your license key goes here")
' Now, we tell Xceed Zip where to create the self-extracting
' zip file. For this sample, we make the zip file name include the
' client's IP address or name in. That way, if multiple users
' are using this ASP page to create zip files at the same time,
' each user has a unique zip filename to download.
sFilename = PATH_FOR_ZIP_FILE & Request.ServerVariables("REMOTE_HOST") & ".exe"
xZip.ZipFilename = sFilename
' Now lets set Xceed Zip's options to customize the self-extracting zip file
sFilesChosen = ""
if uCase(Request("chkFile1")) = "ON" then
sFilesChosen = "File1.txt<BR>"
xZip.AddFilesToProcess (PATH_FOR_SOURCE_FILES & "File1.txt")
end if
if uCase(Request("chkFile2")) = "ON" then
sFilesChosen = sFilesChosen & "File2.txt<BR>"
xZip.AddFilesToProcess (PATH_FOR_SOURCE_FILES & "File2.txt")
end if
if uCase(Request("chkFile3")) = "ON" then
sFilesChosen = sFilesChosen & "File3.txt<BR>"
xZip.AddFilesToProcess (PATH_FOR_SOURCE_FILES & "File3.txt")
end if
xZip.UseTempFile = False ' No need for a temp file for this application
xZip.PreservePaths = False ' Do not store the paths where the source files are from
xZip.SfxBinaryModule = PATH_FOR_SOURCE_FILES & "xcdsfx32.bin"
Introtext = "This self-extracting zip file contains the file(s) you selected "
Introtext = Introtext + "to download. The files are password-protected, so you "
Introtext = Introtext + "will need to enter a password. Click 'OK' to continue."
xZip.SfxMessages(xsmIntro) = Introtext
xZip.SfxStrings(xssTitle) = "Custom zip file for " + Trim(Request("txtIntro")) ' Uses name entered on the web page
xZip.SfxDefaultUnzipToFolder = Trim(Request("txtUnzipFolder")) ' The unzip folder entered on the web page
xZip.EncryptionPassword = Trim(Request("txtPassword")) ' The password entered on the web page
' Now run the command to create the self-extracting zip file
ResultCode = xZip.Zip
If ResultCode = 0 then
sDownloadPath = DOWNLOAD_URL & Request.ServerVariables("REMOTE_HOST") & ".exe"
Response.ContentType = "application/x-gzip"
Response.Redirect (sDownloadPath)
else
%>
<HTML>
<HEAD>
<TITLE>
Custom zip file creation error.
</TITLE>
</HEAD>
<BODY>
<STRONG>
You have selected to download the following files:
<P>
</STRONG>
<BR>
<%
Response.Write(sFilesChosen)
%>
But the following error from Xceed Zip was returned: <P>
<%
Response.Write(xZip.GetErrorDescription(xvtError ,ResultCode))
%></P>
</BODY>
</HTML>
<%
end if
set xZip = Nothing
%>
</BODY>
</HTML>
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.