ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Archive functions
  • Extracting the path of a file found in the archive
zipExtractPath (Example)
Extracting the path of a file found in the archive
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)Ajax
The following code is used to display the path of a file in an archive. The file whose path is extracted is selected in a memory table (TABLE_ArchiveTable). The stored path of the files contains: the name of the directories, the name and extension of the file. ZipExtractPath returns the name and extension of the file.
// Declare and initialize the variables
DirectoryName is string
ArchiveName is string = "MyArchive"
CreationErrorCode is int
AdditionErrorCode is int
ExtractedPath is string
FileIndex is int
 
// Create an archive
CreationErrorCode = zipCreate(ArchiveName, ...
"C:\Directory\Archives\PDFArchive.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 the selected file
    ExtractedPath = zipExtractPath(ArchiveName, FileSubscript, ...
zipFilename + zipExtension)
    // Display the extracted path
IF ExtractedPath <> "" THEN
Info("The name and extension of the file are: " + ...
ExtractedPath)
END
ELSE
    // Display the 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
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