ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Archive functions
  • Use condition
  • Compression level
  • Error codes
  • Adding a file that already exists in the archive
  • Index of files in the archive
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Automatically adds and compresses a list of files into a ZIP, CAB, WDZ, 7z, TAR, gzip or TGZ (TAR.GZ) archive. This function is faster than zipAddFile run for each file.
New in version 2025
Windows gzip (.gz extension) is now supported.
Example
Reports and Queries
// Create an archive and add an element
// With progress bar displayed in a Progress Bar control 
MyArchive is zipArchive
NumZipErr is int

NumZipErr = zipCreate(MyArchive,"C:\Doc\Archive\ArchiveFile.zip")
IF NumZipErr = 0 THEN
	NumZipErr = zipAddFileList(MyArchive, "C:\doc\Image\House.BMP" + CR +  ...
			"C:\My Projects\WDStock\WDStock.wdp", zipDrive, PROGBAR_Progress)
	IF NumZipErr <> 0 THEN
		Error(zipMsgError(NumZipErr))
	END
	zipClose(MyArchive)
ELSE
	Error(zipMsgError(NumZipErr))
END
Syntax

Adding a list of files separated by carriage returns (CR) Hide the details

<Result> = zipAddFileList(<Archive> , <Path of files to add> [, <Path section to store> [, <Progress>]])
<Result>: Integer
  • 0 if the file list 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 the archive into which the files will be added.
This name can correspond to:
<Path of files to add>: Character string
Name and path of files to be added to the archive, separated by carriage returns (CR). These paths can be full paths or paths relative to the current directory. The length of each path must not exceed 260 characters.
The size of each file must not exceed 4 GB. Otherwise, an error occurs.
You cannot use wildcard characters.
Reports and Queries This parameter has the following format:
<File path> [ + TAB + <Path to store> ] + RC
If a path is specified, adding the file will be equivalent to calling zipAddFile followed by zipChangePath.
<Path section to store>: Optional constant
Indicates the file path section to be stored in the archive. This parameter is only taken into account for files for which <Path to store> was not specified.
zipDirectoryStores the different directories that are part of the path, as well as the file name and extension. For example: \Directory\Files\FileName.pdf
zipDrive
(Default value)
Stores the full and absolute path of the file (disk, directories, file name and 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.
zipNoneStores 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. The .CAB format does not allow you to store paths in the archive file.
<Progress>: Control name or procedure name
Progress bar management mode. This parameter can correspond to:
If you use a TAR, gzip or TGZ (TAR.GZ) archive, the progress bar is refreshed only after each file is added.

Adding a list of files contained in an array Hide the details

<Result> = zipAddFileList(<Archive> , <List of files> [, <Progress>])
<Result>: Integer
  • 0 if the file list has been added,
  • An error code (value greater than 0) otherwise. For more details on these error codes, see the Remarks.
<Archive>: zipArchive variable
Name of the archive into which the files will be added.
This name can correspond to:
<List of files>: Array of zipArchivedFile variables
Array of zipArchivedFile variables used to identify the characteristics of the files to be added.
<Progress>: Control name or procedure name
Progress bar management mode. This parameter can correspond to:
If you use a TAR, gzip or TGZ (TAR.GZ) archive, the progress bar is refreshed only after each file is added.
Remarks

Use condition

You can add files to an archive if:
  • The archive exists (archives are created using zipCreate).
  • The archive is accessible in read/write mode.
  • The archive is a single-part archive.
  • The size of the file is less than 4 GB.
Caution:
  • The full path of each file is stored in the archives in ZIP or WDZ format.
  • CAB archives: Files must be added immediately after the archive is created. This format does not allow adding files to an existing archive.
  • RAR archives: This function is not available.
  • 7z archives: The archive is fully compressed each time zipAddFileList is called.
Maximum number of files allowed:
  • in a WDZ file: 232-1.
  • in a ZIP file: 65535.
  • in a CAB file: 65535.
Reminder:

    Compression level

    The files added into a zip archive are compressed by default. You can change the compression level of files added to an archive using function 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(<File name>)
      Multitask(<Timeout>) // Waits until the file is closed
    • 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 already exists in the archive

    Adding a file already present in an archive causes an error. 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 to an archive, an index is automatically assigned to that file. This index corresponds to the order in which the files are added to the archive. To select a file in the archive, you can use:
    • The index of the element (this index is returned by zipFindFile).
    • The stored path of element.
    Business / UI classification: Business Logic
    Component: wd300zip.dll
    Minimum version required
    • Version 9
    This page is also available for…
    Comments
    Click [Add] to post a comment

    Last update: 06/03/2025

    Send a report | Local help