|
|
|
|
|
- Use condition
- Compression level of ZIP or 7z archives
- Error codes
- Adding a file that is already found in the archive
- Index of files in the archive
- Path kept (archives in WDZ or ZIP format)
zipAddFile (Function) In french: zipAjouteFichier Automatically adds and compresses any type of file into a CAB, ZIP, WDZ, 7z, TAR, gzip or TGZ (TAR.GZ) archive. This function cannot be used with RAR archives. Remarks:
New in version 2025MyArchive is zipArchive
ResCreate is int
ResAddFile is int
ResCreate = zipCreate(MyArchive, "C:\Temp\Archive.zip")
IF ResCreate = 0 THEN
ResAddFile = zipAddFile(MyArchive, ...
"C:\MyDirectory\MyFiles\File.pdf", zipDrive)
END
IF ResAddFile <> 0 THEN
Error(zipMsgError(ResAddFile))
END
Syntax
Adding a file and preserving parts of the file path Hide the details
<Result> = zipAddFile(<Archive> , <File path> [, <Path section to keep> [, <Progress>]])
<Result>: Integer - 0 if the file has been added,
- 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 archive into which the file will be added. This name can correspond to: <File path>: Character string Path of the file to be added to the archive (260 characters maximum, 90 maximum for TAR, gzip or TGZ (TAR.GZ) archives). This path can be a full path or a path relative to the current directory. Wildcard characters (*,?) are not allowed in the file name. This file must not exceed 4 GB. Otherwise, an error occurs. <Path section to keep>: Optional constant Indicates the section of the file path that will be kept in the archive: | | zipDirectory (Default value) | Keeps the different directories of the file path as well as the file name and extension. For example: \Directory\Files\FileName.pdf | zipDrive | Keeps the full and absolute file path (name of disk, name of directories, file name and file extension). For example: C:\Directory\Files\FileName.pdf ZIP format: This constant has no effect. 7z format: This constant and zipDirectory will have the same effect. | zipNone | Keeps the file name and extension. For example: FileName.pdf |
If you are using an archive in .CAB format, only the zipNone constant is taken into account. Indeed, the .CAB format cannot be used to save the paths inside the archive. <Progress>: Control name or procedure name Progress bar management mode. This parameter can correspond to:    the name of a Progress Bar control found in a window. The progress bar will display the addition and compression progress of the file being managed. - the name of a WLanguage procedure. For more details on this procedure, see Parameters of the procedure used by zipAddFile.
If you use a TAR, gzip or TGZ (TAR.GZ) archive, the progress bar is refreshed only after the file is added.
Adding a file ignoring parts of the file path Hide the details
<Result> = zipAddFile(<Archive> , <File path> [, <Path section to ignore> [, <Progress>]])
<Result>: Integer - 0 if the file has been added,
- 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 archive into which the file will be added. This name can correspond to: <File path>: Character string Path of the file to be added to the archive (260 characters maximum, 90 maximum for TAR, gzip or TGZ (TAR.GZ) archives). This path can be a full path or a path relative to the current directory. Wildcard characters (*,?) are not allowed in the file name. This file must not exceed 4 GB. Otherwise, an error occurs. <Path section to ignore>: Optional character string Indicates the section of file path that must not be stored in the archive. For example, in WINDEV, if the full path of the file added into the archive is: "C:\My Documents\Work\Report.doc" and if <Path section to ignore> is set to "C:\My Documents\", only the "Work\Report.doc" section will be kept. <Progress>: Control name or procedure name Progress bar management mode. This parameter can correspond to:    the name of a Progress Bar control found in a window. The progress bar will display the addition and compression progress of the file being managed. - the name of a WLanguage procedure. For more details on this procedure, see Parameters of the procedure used by zipAddFile.
If you use a TAR, gzip or TGZ (TAR.GZ) archive, the progress bar is refreshed only after the file is added. Remarks Use condition 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.
- 7z archives: The archive is fully compressed each time zipAddFile is called. This function is recommended when adding a single file. If several files must be added into the archive, use zipAddFileList or zipAddDirectory.
Compression level of ZIP or 7z archives The files added into an archive in ZIP or 7z 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 does not have sufficient rights or the file is in use.. If the file to insert is an HFSQL data file, it must be closed by the following code:
HClose(FileName)
Multitask()
- 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 according to the path saved in the archive. Therefore, two files with the same name and with the same relative path cannot be added into an archive. For example, the zipNone constant cannot be used to add two files with the same but coming from different directories. 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 is returned by zipFindFile).
- or the path of the element saved in the archive.
Path kept (archives in WDZ or ZIP format) The array below shows the paths kept in the archive according to: - the access path to the file,
- the path section to keep.
Business / UI classification: Business Logic
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|