PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Use conditions
  • Compression level
  • Error codes
  • Adding a file that is already found in the archive
  • Subscript of files in the archive
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Adds all the files found in a directory and in its sub-directories into an archive and compresses them. This function can be used on the following types of archives: CAB, ZIP, WDZ, 7z, TAR and TGZ (TAR.GZ).
Versions 18 and later
WINDEVWEBDEV - Server codeWindows This function now supports the 7z format.
New in version 18
WINDEVWEBDEV - Server codeWindows This function now supports the 7z format.
WINDEVWEBDEV - Server codeWindows This function now supports the 7z format.
Versions 21 and later
WINDEVWEBDEV - Server codeWindowsLinux This function now supports the TAR and TGZ (TAR.GZ) formats.
New in version 21
WINDEVWEBDEV - Server codeWindowsLinux This function now supports the TAR and TGZ (TAR.GZ) formats.
WINDEVWEBDEV - Server codeWindowsLinux This function now supports the TAR and TGZ (TAR.GZ) formats.
Example
WINDEVWEBDEV - Server codeUser code (UMC)Ajax
MonArchive est un zipArchive
// Création de l'archive
ResCréation = MonArchive.Crée("C:\Temp\Archive.zip")
SI ResCréation = 0 ALORS
// Ajoute la totalité des fichiers d'un répertoire
ResAjoutRép = MonArchive.AjouteRépertoire(...
"C:\MonRépertoire\MesFichiers", Vrai, zipDisque)
FIN
// Affichage du message d'erreur si l'ajout n'a pas été effectué
SI ResAjoutRép <> 0 ALORS Erreur(zipMsgErreur(ResAjoutRép))
Windows Mobile
MonArchive est un zipArchive
// Création de l'archive
ResCréation = MonArchive.Crée("\Temp\Archive.zip")
SI ResCréation = 0 ALORS
// Ajoute la totalité des fichiers d'un répertoire
ResAjoutRép = MonArchive.AjouteRépertoire(...
"\MonRépertoire\MesFichiers", Vrai)
FIN
// Affichage du message d'erreur si l'ajout n'a pas été effectué
SI ResAjoutRép <> 0 ALORS Erreur(zipMsgErreur(ResAjoutRép))
Syntax

Adding the directory files while specifying the path to store Hide the details

<Result> = <Archive>.AddDirectory(<Directory path> [, <Subdirectory> [, <Path section to store> [, <WLanguage procedure> [, <Progress>]]]])
<Result>: Integer
  • 0 if the addition was performed,
  • An error code (value greater than 0) otherwise. For more details on these error codes, see the Remarks.
<Archive>: zipArchive variable
Name of a zipArchive variable that corresponds to the archive into which the content of the directory will be added.
<Directory path>: Character string (with quotes)
Path of directory that will be added into the archive (up to 260 characters). This path can be a full path or a path relative to the current directory. The function returns an error if this parameter corresponds to an empty string ("").
The size of the files found in this directory must be less than 4 GB. Otherwise, an error occurs.
Windows Mobile The access path to the file is a full path. Indeed, the notion of current directory does not exist on Pocket PC.
<Subdirectory>: Optional boolean
  • True (default value) if the sub-directories must be added,
  • False if the sub-directories must not be added.
<Path section to store>: Optional constant
Path section to store for each file in the archive:
zipDriveStore the full and absolute path of file (name of disk, name of directories, file name and file extension). For example: C:\Directory\Files\FileName.pdf
For the WDZ format: The full path of file (including the drive letter) is stored.
For the ZIP format: The drive letter is not stored.
For the 7z format: This constant and zipDirectory will have the same effect.
LinuxWindows Mobile This constant is not available as there is no root for the drive.

zipRelativeThe path passed in parameter is considered as being the root of the archive. The stored path for all files and sub-directories is given in relation to this root.
Therefore, if the added directory is: "C:\Temp\Doc" containing the following elements:
  • the Test1.doc file,
  • the Test2.doc file is found in the SYS sub-directory,
the stored information will be relative to the "C:\Temp\Doc" directory:
  • Test1.doc,
  • SYS\Test2.Doc.
zipDirectory
(Default value)
Stores the different directories found in the file path as well as the file name and extension. For example: \Directory\Files\FileName.pdf

Archive in .CAB format: None of these constants is taken into account. Indeed, the .CAB format cannot be used to store the paths inside the archive.
<WLanguage procedure>: Optional procedure name
Name of WLanguage procedure that will be called before adding each file. This procedure allows you to archive a tree structure while omitting one or more files.
For more details on this procedure, see Parameters of the Procedure used by the <zipArchive variable>.AddDirectory function to manage the addition of files.
WEBDEV - Server code This procedure must be a server procedure.
<Progress>: Control name or procedure name
Versions 21 and later
Progress bar management mode. This parameter can correspond to:
If you are handling a TAR or TGZ (TAR.GZ)archive, the gauge is updated only at the end of each file addition.
WEBDEV - Server code The procedure must be a server procedure.
New in version 21
Progress bar management mode. This parameter can correspond to:
If you are handling a TAR or TGZ (TAR.GZ)archive, the gauge is updated only at the end of each file addition.
WEBDEV - Server code The procedure must be a server procedure.
Progress bar management mode. This parameter can correspond to:
If you are handling a TAR or TGZ (TAR.GZ)archive, the gauge is updated only at the end of each file addition.
WEBDEV - Server code The procedure must be a server procedure.

Adding the files found in a directory while specifying the path to ignore Hide the details

<Result> = <Archive>.AddDirectory(<Directory path> [, <Subdirectory> [, <Path section to ignore> [, <WLanguage procedure> [, <Progress>]]]])
<Result>: Integer
  • 0 if the addition was performed,
  • An error code (value greater than 0) otherwise. For more details on these error codes, see the Remarks.
<Archive>: zipArchive variable
Name of a zipArchive variable that corresponds to the archive into which the content of the directory will be added.
<Directory path>: Character string (with quotes)
Path of directory that will be added into the archive (up to 260 characters). This path can be a full path or a path relative to the current directory.
The function returns an error if this parameter corresponds to an empty string ("").
The size of the files found in this directory must be less than 4 GB. Otherwise, an error occurs
Windows Mobile The access path to the file is a full path. Indeed, the notion of current directory does not exist on Pocket PC.
<Subdirectory>: Optional boolean
  • True (default value) if the sub-directories must be added,
  • False if the sub-directories must not be added.
<Path section to ignore>: Optional character string (with quotes)
Indicates the section of file path that must not be stored in the archive. For example, if the full path of the directory added into the archive is: "C:\My Documents\Work\" and if <Section of path to ignore> is set to "C:\My Documents\", on the "Work\" section will be stored.
<WLanguage procedure>: Optional procedure name
Name of WLanguage procedure that will be called before adding each file. This procedure allows you to archive a tree structure while omitting one or more files. For more details on this procedure, see Parameters of the Procedure used by the <zipArchive variable>.AddDirectory function to manage the addition of files.
WEBDEV - Server code This procedure must be a server procedure.
<Progress>: Control name or procedure name
Versions 21 and later
Progress bar management mode. This parameter can correspond to:
If you are handling a TAR or TGZ (TAR.GZ)archive, the gauge is updated before and at the end of each file addition.
WEBDEV - Server code The procedure must be a server procedure.
New in version 21
Progress bar management mode. This parameter can correspond to:
If you are handling a TAR or TGZ (TAR.GZ)archive, the gauge is updated before and at the end of each file addition.
WEBDEV - Server code The procedure must be a server procedure.
Progress bar management mode. This parameter can correspond to:
If you are handling a TAR or TGZ (TAR.GZ)archive, the gauge is updated before and at the end of each file addition.
WEBDEV - Server code The procedure must be a server procedure.
Remarks

Use conditions

Adding files into an archive can be performed if:
  • The archive exists (an archive is created by <zipArchive variable>.Create).
  • The archive is accessible in read/write.
  • The archive is a single-part archive.
  • The size of the file is less than 4 GB.
Caution:
  • Archives in CAB format: The files must be added immediately after the archive creation. This format cannot be used to add files into an existing archive.
  • Archives in RAR format: This function is not available.
  • Archives in 7z format: The archive is entirely compressed whenever <zipArchive variable>.AddDirectory is called.
The maximum number of files that can be included:
  • in a WDZ file: 232-1.
  • in a ZIP file: 65535.
  • in a CAB file: 65535.
Remark: If the zipHeader64 constant is used when creating the archive (<zipArchive variable>.Create), you will have the ability to create archives exceeding 4 GB. Reminder:
  • Linux Only ZIP, TAR and TGZ (TAR.GZ) archives are available.
  • Windows Mobile Only ZIP archives are available.

Compression level

The files added into an archive in Zip format are compressed by default. The compression level of files added into an archive can be modified by zipCompressionLevel.

Error codes

The following error codes are returned:
  • 1: The path passed as parameter does not exist.
  • 2: Access denied: the user has no sufficient rights.
  • 3: The archive is corrupted.
  • 4: The path does not exist in the archive.
  • 5: Unable to write into the archive.
  • 7: The file is already found in the archive.
  • 8: An archive cannot be added to itself. For example, "MyArchive" cannot be added to "MyArchive".
The message corresponding to the error code is returned by zipMsgError.

Adding a file that is already found in the archive

An error occurs when adding a file that is already found in the archive. A file is identified by its stored path. Therefore, two files with the same name and with the same relative path cannot be added into an archive.

Subscript of files in the archive

When a file is added into an archive, a subscript is automatically assigned to the file. This subscript corresponds to the order in which the files are included in the archive. To select a file in the archive, you can use:
  • The subscript of the element. (Remark: the subscript of an element can be known thanks to the zipFindFile function )
  • The stored path of element.
Component: wd260zip.dll
Minimum version required
  • Version 24
This page is also available for…
Comments
Click [Add] to post a comment