|
|
|
|
|
- Use conditions
- Compression level
- Error codes
- Adding a file that is already found in the archive
- Index of files in the archive
zipAddDirectory (Function) In french: zipAjouteRépertoire 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 CAB, ZIP, WDZ, 7z, TAR, gzip and TGZ (TAR.GZ) archives. New in version 2025Syntax
Adding the directory files while specifying the path to store Hide the details
<Result> = zipAddDirectory(<Archive> , <Directory path> [, <Subdirectory> [, <Storing option> [, <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>: Character string or zipArchive variable Name of the archive into which the content of the directory must be added. This name can correspond to: <Directory path>: Character string 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. <Subdirectory>: Optional boolean - True (default value) if the sub-directories must be added,
- False if subdirectories are not to be added.
<Storing option>: Optional constant Path section to store for each file in the archive: | | 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 | zipDrive | Store 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 WDZ format: The full path of the file (including drive letter) is stored.. For ZIP format: The drive letter is not memorized. 7z format: This constant and zipDirectory will have the same effect.
| zipRelative | The path passed as 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. Thus, if the added directory is: "C:\Temp\Doc" containing the following items:- the Test1.doc file,
- the Test2.doc file is located in the SYS subdirectory,
the stored information will be relative to the "C:\Temp\Doc" directory:- Test1.doc,
- SYS\Test2.Doc.
|
Archive in .CAB format: none of these constants are 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 zipAddDirectory to manage the addition of files. <Progress>: Control name or procedure name Progress bar management mode. This parameter can correspond to: If you're handling an archive in TAR, gzip or TGZ (TAR.GZ)format, the ProgressBar is updated only when each file has been added.
Adding the files found in a directory while specifying the path to ignore Hide the details
<Result> = zipAddDirectory(<Archive> , <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>: Character string or zipArchive variable Name of the archive into which the content of the directory must be added. This name can correspond to: <Directory path>: Character string 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 <Subdirectory>: Optional boolean - True (default value) if the sub-directories must be added,
- False if subdirectories are not to be added.
<Path section to ignore>: Optional character string Indicates the section of file path that must not be stored in the archive. For example, if the full path of the directory added to the archive is: "C:\Mes Documents\Travail\" and the parameter <Portion du chemin à ignorer> is "C:\Mes Documents\", only the "Travail\" portion will be saved. <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 zipAddDirectory to manage the addition of files. <Progress>: Control name or procedure name Progress bar management mode. This parameter can correspond to: If you're working with an archive in TAR, gzip or TGZ (TAR.GZ)format, the ProgressBar is updated before and after each file is added.. Remarks Use conditions Adding files into an archive can be performed if: - The archive exists (archives are created using zipCreate).
- 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: - CAB archives: Files must be added immediately after the archive is created. This format cannot be used to add files into an existing archive.
- RAR archives: This function is not available.
- Archives in 7z format: The archive is fully compressed each time the function is called zipAddDirectory.
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 constant zipEntête64 is used when creating the archive (function zipCreate), it will be possible to create archives larger than 4 gigas..
Reminder: Only ZIP, TAR, gzip and TGZ (TAR.GZ) archives are available. Only ZIP archives are available.
Compression level The files added into a zip archive 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: user does not have sufficient rights.
- 3: The archive is corrupted.
- 4: The path does not exist in the archive.
- 5: Unable to write to the archive.
- 7: The file already exists 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. Index of files in the archive When a file is added into an archive, an index is automatically assigned to the file. This index corresponds to the order in which the files are included in the archive. To select a file in the archive, you can use: - The index of the element. (Note: the index of an element can be known using the zipFindFile function)
- The stored path of the element.
Business / UI classification: Business Logic
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|