ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Archive functions
  • Example 1: Calculating the size of an archive file according to its subscript
  • Example 2: Calculating the size of an archive file according to its stored path
zipFileSize (Example)
Example 1: Calculating the size of an archive file according to its subscript
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)Ajax The following code is used to calculate the size of an archive file before extracting it. If the user confirms the extraction of the file, the file is extracted.
In this example, we will assume that the archive is already opened and that the file (whose size is requested) is selected in 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.
// --Click code of BTN_ExtractFile
// Declare and initialize the variables
FileIndex is int
FileSize is int
ErrorCodeExtract is int
ArchiveName is string = "MyArchive"
 
// Select the file in the archive
FileIndex = TableSelect(TABLE_ArchiveTable)
 
// Initial size of the file
FileSize = zipFileSize(ArchiveName, FileSubscript)
 
// Extract the selected file
IF YesNo("This file will occupy: " + FileSize, "Do you want to extract this file?") THEN
// Extract the file
ErrorCodeExtract = zipExtractFile(ArchiveName, FileSubscript)
// Display an error message if the file was not extracted
IF ErrorCodeExtract <> 0 THEN
Error(zipMsgError(ErrorCodeExtract))
END
END
Example 2: Calculating the size of an archive file according to its stored path
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)Ajax The following code is used to calculate the size of an archive file before extracting it.
In this example, we will assume that the archive is already opened and that the file (whose size is requested) is selected according to its stored path.
// --Click code of BTN_ExtractFile
 
// Declare and initialize the variables
FileSize is int
ErrorCodeExtract is int
ArchiveName is string = "MyArchive"
 
// Initial size of the file
FileSize = zipFileSize(ArchiveName, "Files\File.txt")
 
// Extract the selected file
IF YesNo("The File.txt file will occupy: " + FileSize, ...
"Do you want to extract this file?") THEN
    // Extract the file
    ErrorCodeExtract = zipExtractFile(ArchiveName, "Files\File.txt")
    // Display an error message if the file was not extracted
    IF ErrorCodeExtract <> 0 THEN
Error(zipMsgError(ErrorCodeExtract))
    END
END
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