PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
This content has been translated automatically. Click here to view the French version.
  • 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)
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Adds a file (of any type) into an archive in CAB, ZIP, WDZ and 7z, TAR or TGZ (TAR.GZ) format and compresses it. This function cannot be used on the RAR archives.
To add the files found in a directory, use zipAddDirectory.
Versions 15 and later
Android This function is now available for Android applications.
New in version 15
Android This function is now available for Android applications.
Android This function is now available for Android applications.
Versions 17 and later
iPhone/iPad This function is now available for iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for iPhone/iPad applications.
iPhone/iPad This function is now available for iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android widget mode.
WINDEVWEBDEV - Server codeWindows This function now supports the 7z format.
New in version 18
Android Widget This function is now available in Android widget mode.
WINDEVWEBDEV - Server codeWindows This function now supports the 7z format.
Android Widget This function is now available in Android widget mode.
WINDEVWEBDEV - Server codeWindows This function now supports the 7z format.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
WINDEVWEBDEV - Server codeWindowsLinuxUniversal Windows 10 AppiPhone/iPad This function now supports the TAR and TGZ (TAR.GZ) formats.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
WINDEVWEBDEV - Server codeWindowsLinuxUniversal Windows 10 AppiPhone/iPad This function now supports the TAR and TGZ (TAR.GZ) formats.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
WINDEVWEBDEV - Server codeWindowsLinuxUniversal Windows 10 AppiPhone/iPad This function now supports the TAR and TGZ (TAR.GZ) formats.
MonArchive is zipArchive
// Création de l'archive
ResCréation = zipCreate(MonArchive, "C:\Temp\Archive.zip")
IF ResCréation = 0 THEN
// Ajout d'un fichier dans une archive
ResAjoutFichier = zipAddFile(MonArchive, ...
"C:\MonRépertoire\MesFichiers\Fichier.pdf", zipDrive)
END
// Affichage du message d'erreur si le fichier n'a pas été ajouté
IF ResAjoutFichier <> 0 THEN
Error(zipMsgError(ResAjoutFichier))
END
Syntax

Adding a file while specifying the path section to keep Hide the details

<Result> = zipAddFile(<Archive> , <File path> [, <Path section to keep> [, <Progress>]])
<Result>: entier
  • 0 if the addition was performed,
  • an error code (value greater than 0) otherwise. For more details on these error codes, see the the remarks.
<Archive>: Character string (with quotes) or zipArchive variable
Name of archive into which the file will be added.
This name can correspond to:
  • the name of an archive, defined by zipOpen or zipCreate.
  • Versions 15 and later
    WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadIOS WidgetMac CatalystAjax the name of a variable of type zipArchive.
    New in version 15
    WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadIOS WidgetMac CatalystAjax the name of a variable of type zipArchive.
    WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadIOS WidgetMac CatalystAjax the name of a variable of type zipArchive.
    Versions 26 and later
    AndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst zipArchive variables are now available.
    New in version 26
    AndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst zipArchive variables are now available.
    AndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst zipArchive variables are now available.
<File path>: Character string (with quotes)
Path of the file to be added to the archive (260 characters maximum, 90 maximum in the case of an archive in TAR or TGZ format (TAR.GZ)). This path can be a full path or a path relative to the current directory. The wildcard characters (*,?) are not allowed in the file name.
The size of this file must not exceed 4 GB. Otherwise, an error occurs.
Universal Windows 10 App The access path to the file is a full path or a path relative to the working directory of the application (returned by fDataDir). Only the files found in the working directory can be added to the archive.
<Path section to keep>: Optional constant
Indicates the section of the file path that will be kept in the archive:
zipNoneKeeps the file name and extension. For example: FileName.pdf
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
zipDriveKeeps the full and absolute file path (name of disk, name of directories, file name and file extension). For example: C:\Directory\Files\FileName.pdf
For the ZIP format: This constant has no effect.
For the 7z format: This constant and zipDirectory will have the same effect
LinuxiPhone/iPadIOS WidgetMac Catalyst This constant is not available as there is no root for the drive.
AndroidAndroid Widget Java This constant and zipDirectory will have the same effect.

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.
Universal Windows 10 App This parameter is not available: only the file name and extension are kept.
<Progress>: Control name or procedure name
Versions 21 and later
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
WEBDEV - Server code The procedure must be a server procedure.
Java This parameter is not available.
New in version 21
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
WEBDEV - Server code The procedure must be a server procedure.
Java This parameter is not available.
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
WEBDEV - Server code The procedure must be a server procedure.
Java This parameter is not available.
Universal Windows 10 App Not available in Universal Windows 10 App

Adding a file while specifying the path to ignore Hide the details

<Result> = zipAddFile(<Archive> , <File path> [, <Path section to ignore> [, <Progress>]])
<Result>: entier
  • 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 (with quotes) or zipArchive variable
Name of archive into which the file will be added.
This name can correspond to:
  • the name of an archive, defined by zipOpen or zipCreate.
  • Versions 15 and later
    WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadIOS WidgetMac CatalystAjax the name of a variable of type zipArchive.
    New in version 15
    WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadIOS WidgetMac CatalystAjax the name of a variable of type zipArchive.
    WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadIOS WidgetMac CatalystAjax the name of a variable of type zipArchive.
    Versions 26 and later
    AndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst zipArchive variables are now available.
    New in version 26
    AndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst zipArchive variables are now available.
    AndroidAndroid Widget iPhone/iPadIOS WidgetMac Catalyst zipArchive variables are now available.
<File path>: Character string (with quotes)
Path of the file to be added to the archive (260 characters maximum, 90 maximum in the case of an archive in TAR or TGZ format (TAR.GZ)). This path can be a full path or a path relative to the current directory. The wildcard characters (*,?) are not allowed in the file name.
The size of this file must not exceed 4 GB. Otherwise, an error occurs.
<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, 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
Versions 21 and later
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
WEBDEV - Server code The procedure must be a server procedure.
Java This parameter is not available.
New in version 21
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
WEBDEV - Server code The procedure must be a server procedure.
Java This parameter is not available.
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
WEBDEV - Server code The procedure must be a server procedure.
Java This parameter is not available.
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadIOS WidgetMac CatalystUser code (UMC)Ajax

Adding a file found in a buffer (WDZ and ZIP format only) Hide the details

<Result> = zipAddFile(<Archive> , <File to add> , <Buffer management> , <Path to keep> [, <Progress>])
<Result>: entier
  • 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 (with quotes) or zipArchive variable
Name of archive into which the file will be added.
This name can correspond to:
<File to add>: Buffer
Buffer that corresponds to the file content that will be added into the archive.
<Buffer management>: Constant
Mode for managing the buffer:
zipInMemorySaves the content of the buffer (i.e. the file) in the archive.
<Path to keep>: Character string (with quotes)
File path or file name associated with the buffer that will be kept in the archive.
<Progress>: Control name or procedure name
Versions 21 and later
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
WEBDEV - Server code The procedure must be a server procedure.
New in version 21
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
WEBDEV - Server code The procedure must be a server procedure.
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
WEBDEV - Server code The procedure must be a server procedure.
Versions 15 and later
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadIOS WidgetMac CatalystUser code (UMC)Ajax

Adding a file by using a zipArchivedFile variable Hide the details

<Result> = zipAddFile(<Archive> , <Fichians> [, <Progress>])
<Result>: entier
  • 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 (with quotes) or zipArchive variable
Name of archive into which the file will be added.
This name can correspond to:
<Fichians>: zipArchivedFile variable
Name of the Variable of type zipArchivedFile containing all the information about the file to be added (including its content).
The file does not necessarily have to exist on the disk: only the information found in this parameter is taken into account.
<Progress>: Control name or procedure name
Versions 21 and later
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
New in version 21
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
New in version 15
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadIOS WidgetMac CatalystUser code (UMC)Ajax

Adding a file by using a zipArchivedFile variable Hide the details

<Result> = zipAddFile(<Archive> , <Fichians> [, <Progress>])
<Result>: entier
  • 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 (with quotes) or zipArchive variable
Name of archive into which the file will be added.
This name can correspond to:
<Fichians>: zipArchivedFile variable
Name of the Variable of type zipArchivedFile containing all the information about the file to be added (including its content).
The file does not necessarily have to exist on the disk: only the information found in this parameter is taken into account.
<Progress>: Control name or procedure name
Versions 21 and later
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
New in version 21
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadIOS WidgetMac CatalystUser code (UMC)Ajax

Adding a file by using a zipArchivedFile variable Hide the details

<Result> = zipAddFile(<Archive> , <Fichians> [, <Progress>])
<Result>: entier
  • 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 (with quotes) or zipArchive variable
Name of archive into which the file will be added.
This name can correspond to:
<Fichians>: zipArchivedFile variable
Name of the Variable of type zipArchivedFile containing all the information about the file to be added (including its content).
The file does not necessarily have to exist on the disk: only the information found in this parameter is taken into account.
<Progress>: Control name or procedure name
Versions 21 and later
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
New in version 21
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
Progress bar management mode. This parameter can correspond to:
  • WINDEVUniversal Windows 10 AppAndroidiPhone/iPadMac Catalyst 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 are using an archive in TAR or TGZ (TAR.GZ) format, the progress bar is updated at the end of file addition only.
Remarks

Use condition

Adding files into an archive can be performed if:
  • The archive exists (an archive is created by 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:
  • 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 7z format: The archive is entirely compressed whenever 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.
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.
Reminder:
  • LinuxUniversal Windows 10 AppiPhone/iPadIOS WidgetMac Catalyst Only the archives in ZIP, TAR or TGZ (TAR.GZ) format are available.
  • AndroidAndroid Widget Java Only ZIP archives are available. Java Only ZIP archives are available.
  • AndroidAndroid Widget The CAB format is not available.

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 has no sufficient rights or the file is currently used. If the file to insert is an HFSQL data file, it must be closed by the following code:
    HClose(NomFichier)
    Multitask() // Attend la fermeture effective du fichier
  • 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 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 name found in 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 element subscript (remark: the subscript of an element can be known thanks to the zipFindFile function).
  • 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.
WINDEVWEBDEV - Server code The current directory is: "C:\Temp":
zipAddFileFile locationzipNonezipDirectoryzipDrive
zipAddFile
("Archi", "File.txt")
C:\Temp\File.txtFile.txtFile.txtFile.txt
zipAddFile
("Archi", "Data\File.txt")
C:\Temp\Data\File.txtFile.txtData\File.txtData\File.txt
zipAddFile
("Archi", "D:\Data\File.txt")
D:\Data\File.txtFile.txtData\File.txtD:\Data\File.txt

Remark: If the constant zipDrive is used, the WDZ format keeps the full path of the file (including the drive letter) while the ZIP format does not keep the drive letter.

AndroidAndroid Widget Java The disk is not kept in the archive path.
Universal Windows 10 App The directory and disk are not kept in the archive path. Only the file name and extension are kept.
Business / UI classification: Business Logic
Component: wd270zip.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment