AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de archivos
  • Error codes
  • Extracted file
  • Extraction and password
  • Index of files in the archive
  • Stored path
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Extracts a file from an archive and automatically decompresses it to a physical location or in memory.
Advertencia
This method of extracting files from an archive can be relatively slow. To extract multiple files, use functions zipExtractAll or zipExtractDirectory.
Novedad versión 2025
WEBDEV - Código ServidorWindowsLinux The gzip format (.gz extension) is now supported.
WEBDEV - Código ServidorAjax
Archive is zipArchive
// Open an archive
ResOpenArchive = zipOpen(Archive, "C:\Archives\Archive.zip")
IF ResOpenArchive = 0 THEN
	...
	 // Extract a file to its initial location
	 ResExtractFile = zipExtractFile(Archive, "File.txt", zipDrive)
	...
END
Sintaxis

Extracting a file identified by its index Ocultar los detalles

<Result> = zipExtractFile(<Archive> , <File index> [, <File destination> [, <Progress>]])
<Result>: Integer or buffer
  • 0 if the file was extracted,
  • An error code (value greater than 0) otherwise. For more details on these error codes, see the Remarks.
When extracting "in memory", corresponds to the buffer containing the extracted file.
<Archive>: Character string or zipArchive variable
Name of the archive to be used.
This name can correspond to:
<File index>: Integer
Index of file to extract from the archive. zipFindFile returns this index.
<File destination>: Optional character string or constant
Destination path of extracted file:
  • Optional character string: The file is extracted to the specified path, to which the file's memorized tree structure is added (the disk is not preserved). The specified path is created if it does not exist.
  • Optional constant:
    zipDirectory
    (Default value)
    Extraction into the current directory while restoring the tree structure of file (if it was stored).
    zipDriveExtraction:
    • to the initial file location if it was stored and if the drive exists.
    • while restoring the tree structure of the file on the current drive if the drive or the stored directory does not exist.
    • into the current directory if only the file name and extension have been stored.
    Linux This constant is not available. The directories have no root.

    Archives in format 7z: This constant will have the same effect as the constant zipDirectory.
    zipInMemoryExtracts the file in memory. The file content is directly returned by the function. It can be assigned to a Buffer variable for example.
    This feature is available for ZIP and WDZ archives only.
    zipNoneExtraction into the current directory without restoring the tree structure of file (if it was stored).
<Progress>: Control name or procedure name
Progress bar management mode. This parameter can correspond to:
  • the name of a WLanguage procedure. This procedure has the following format:
    <Procedure name> (<Current file>, <Progress percentage>)

    where:
    • <Current file> corresponds to the name of the file currently processed.
    • <Progress percentage> corresponds to the progress percentage of the file being extracted from the archive.
Please note: The ProgressBar is only updated at the end of file extraction for:
  • TAR, gzip or TGZ (TAR.GZ),
  • RAR,
  • CAB.

Extracting a file identified by its path Ocultar los detalles

<Result> = zipExtractFile(<Archive> , <File path> [, <File destination> [, <Progress>]])
<Result>: Integer or buffer
  • 0 if the file was extracted,
  • An error code (value greater than 0) otherwise. For more details on these error codes, see the Remarks.
When extracting "in memory", corresponds to the buffer containing the extracted file.
<Archive>: Character string or zipArchive variable
Name of the archive to be used.
This name can correspond to:
<File path>: Character string
Stored path of file to extract from the archive. Performs an exact-match search on the path of file in the archive.
<File destination>: Optional character string or constant
Destination path of extracted file:
  • Optional character string: The file is extracted to the specified path, to which the file's memorized tree structure is added (the disk is not preserved). The specified path is created if it does not exist.
  • Optional constant:
    zipDirectory
    (Default value)
    Extraction into the current directory while restoring the tree structure of file (if it was stored).
    zipDriveExtraction:
    • to the initial file location if it was stored and if the drive exists.
    • while restoring the tree structure of the file on the current drive if the drive or the stored directory does not exist.
    • into the current directory if only the file name and extension have been stored.
    Linux This constant is not available. The directories have no root.
    Archives in format 7z: This constant will have the same effect as the constant zipDirectory.
    zipInMemoryExtracts the file in memory. The file content is directly returned by the function. It can be assigned to a Buffer variable for example.
    This feature is available for ZIP and WDZ archives only.
    zipNoneExtraction into the current directory without restoring the tree structure of file (if it was stored).
<Progress>: Control name or procedure name
Progress bar management mode. This parameter can correspond to:
  • the name of a WLanguage procedure. This procedure has the following format:
    <Procedure name> (<Current file>, <Progress percentage>)

    where:
    • <Current file> corresponds to the name of the file currently processed.
    • <Progress percentage> corresponds to the progress percentage of the file being extracted from the archive.
Please note: The ProgressBar is only updated at the end of file extraction for:
  • TAR, gzip or TGZ (TAR.GZ),
  • RAR,
  • CAB.
Observaciones

Error codes

The following error codes are returned:
  • 1: Path passed as parameter does not exist.
  • 2: Access denied: user does not have sufficient rights.
  • 3: The archive is corrupt.
  • 4: The path does not exist in the archive.
  • 6: Sub-archive files are not in order (case of extraction from a multi-part archive).
  • 21: The password specified is not correct.
The message corresponding to the error code is returned by zipMsgError. Reminder:
  • Linux Only archives in ZIP, TAR, gzip and TGZ (TAR.GZ) formats are available.
  • RAR is supported up to and including version 4.

Extracted file

The extracted file is not deleted from the archive. To delete one file or all the files from the archive, use zipDeleteFile or zipDeleteAll.
WEBDEV - Código ServidorAjax

Extraction and password

If the file is not encrypted and if zipPassword was used:
  • Archive in WDZ format: The file is still extracted.
  • Archive in ZIP format: An error appears.

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 (the index of an element is returned by zipFindFile).
  • the stored path of the element.

Stored path

The table below presents the paths stored in the archive according to:
  • the access path to the file,
  • the stored path section.
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 zipDisk is used:
  • the WDZ format stores the full path of the file (including the drive letter).
  • the ZIP format does not store the drive letter.
  • the 7z format stores the directories only.
Clasificación Lógica de negocio / UI: Lógica de negocio
Componente: wd300zip.dll
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local