AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de archivos
  • Example 1: Extracting a file from the archive based on its index
  • Example 2: Extracting a file according to its path while displaying a progress bar
zipExtractFile (Example)
Example 1: Extracting a file from the archive based on its index
WEBDEV - Código ServidorAjax The following code is used to extract a file from an archive and to decompress it. The stored path of the files contains: the name of the directories, the name and extension of the file (ZipDirectory constant). The extracted file is copied onto a diskette ("A:\Archive"). The file to extract is selected from a Table control populated programmatically (TABLE_ArchiveTable).
Caution: In order for the index of the Table control populated programmatically to match the index of the selected file, the Table control must not be sorted.
// Declare and initialize the variables
DirectoryName is string
ArchiveName is string = "MyArchive"
CreationErrorCode is int
AdditionErrorCode is int
ErrorCodeExtract is int
FileIndex is int
 
// Create an archive
CreationErrorCode = zipCreate(ArchiveName, "C:\Directory\Archives\ArchivePdf.wdz")
 
IF CreationErrorCode = 0 THEN
// Select the directory
DirectoryName = fSelectDir("", "", "Directory to add")
// Add all the files found in the selected directory
// and subdirectories to the archive
AdditionErrorCode = zipAddDirectory(ArchiveName, DirectoryName, True, zipDirectory)
IF AdditionErrorCode = 0 THEN
    // Select the file in the archive
    FileIndex = TableSelect(TABLE_ArchiveTable)
    // Extract and decompress the selected file
    // Copy the extracted file
    ErrorCodeExtract = zipExtractFile(ArchiveName, FileIndex, "C:\Temp\Archive")
IF ErrorCodeExtract <> 0 THEN
Error(zipMsgError(ErrorCodeExtract))
END
ELSE
    // Display an error message if the files have not been added
    Error(zipMsgError(AdditionErrorCode))
END
ELSE
// Display an error message if the archive was not created
Error(zipMsgError(CreationErrorCode))
END
Example 2: Extracting a file according to its path while displaying a progress bar
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/05/2022

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