Accueil > > > CREATION DE FICHIER ZIP EN ASP
CREATION DE FICHIER ZIP EN ASP
Information sur la source
Description
ce code permet de creer des fichier zip en asp
Source
- <%@ 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>
<%@ 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>
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
IMAGINE CUP 2012, MAKE A SIGN EN FINALEIMAGINE CUP 2012, MAKE A SIGN EN FINALE par junarnoalg
Voilà qui est fait, la nouvelle est officielle ! L'équipe belge "Make a Sign" va au pays des kangourous défendre son projet dans la catégorie Software Design. http://www.imaginecup.com/CompetitionsContent/Competition/WorldwideFinalists.aspx V...
Cliquez pour lire la suite de l'article par junarnoalg KINECT 1.5 IS OUT !KINECT 1.5 IS OUT ! par Vko
La version 1.5 du Kinect For Microsoft vient tout juste de sortir ! Plein de nouveautés: Tracking de squelette en Near Mode Détection en position assise Détection faciale avec un SDK dédié Documentation et des guideline (enfin) Un out...
Cliquez pour lire la suite de l'article par Vko LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) LES ACTUALITéS DE LA SEMAINE SUR C2I.FR (14 MAI - 20 MAI) par richardc
Mise à jour des Web API du 14 Mai
Réservez dès maintenant votre journée du 20 juin pour le Windows Azure Dev Camp 2012 à Paris
Mise à jour de Team Foundation Service
MechCommander 2 sur Windows 8
Entity Framework 5 Release Candidate e...
Cliquez pour lire la suite de l'article par richardc REACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITERREACTIVE EXTENSIONS : CONSOMMER DES SERVICES AVEC RX PARTIE 3, LES PIèGES à éVITER par Groc
Une mauvaise utilisation de rx lors de l'écriture d'une couche d'accès à des services peut conduire à des cas embarassants avec des erreurs mal gérées, des appels qui ne partent lorsqu'ils le devraient, et même des résultats incorrects . le tout nuis...
Cliquez pour lire la suite de l'article par Groc SHAREPOINT BLOG SITE, PROBLèME D'ARCHIVESSHAREPOINT BLOG SITE, PROBLèME D'ARCHIVES par junarnoalg
Dernièrement, nous avons migré le site
myTIC
vers un nouveau serveur SharePoint 2010. Dans les contenus que nous vouloins récupérer, nous avions un certain nombre de blogs.
Nous avons utilisé les commandes Power...
Cliquez pour lire la suite de l'article par junarnoalg
Forum
GRIDVIEW CHECKBOXGRIDVIEW CHECKBOX par invent001
Cliquez pour lire la suite par invent001 OUTIL MYSQLOUTIL MYSQL par nobla
Cliquez pour lire la suite par nobla
Logiciels
sDEVIS-FACTURES vlPRO (8.1.0.3)SDEVIS-FACTURES VLPRO (8.1.0.3)sDEVIS-FACTURES vlPRO a été mis au point pour les particuliers, créateurs, entrepreneurs, artisa... Cliquez pour télécharger sDEVIS-FACTURES vlPRO 974 Application Server (12.2.4.6)974 APPLICATION SERVER (12.2.4.6)Développez de puissantes applications dans un environnement de 'cloud computing', clusterisé, séc... Cliquez pour télécharger 974 Application Server vPicture (1.4.2.1)VPICTURE (1.4.2.1)Avec vPicture, hébergez vos images facilement et rapidement.
vPicture est un utilitaire simple, ... Cliquez pour télécharger vPicture Easy-Planning (2.2.1.6)EASY-PLANNING (2.2.1.6)Easy-Planning permet de créer des plannings sous la représentation de diagrammes et est adapté au... Cliquez pour télécharger Easy-Planning COM-BACKUP (2.0)COM-BACKUP (2.0)
COM-BACKUP est un logiciel de sauvegarde qui permet de planifier les sauvegardes de vos dossiers ...
Cliquez pour télécharger COM-BACKUP
|