ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Archive functions
  • 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 - Server codeAjax 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
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help