ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Archive functions
  • Example 1: Displaying information about a file found in an archive according to its subscript
  • Example 2: Displaying information about a file found in an archive according to its path
zipInfoFile (Example)
Example 1: Displaying information about a file found in an archive according to its subscript
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)Ajax The following code is used to display information about a file found in an archive. The file whose information is displayed is selected in a memory Table (TABLE_ArchiveTable) control. Caution: In order for the subscript of the memory Table to correspond to the subscript of the selected file, the memory Table control must not be sorted.
// Declare and initialize the variables
sDirectoryName is string
sArchiveName is string = "MyArchive"
nCreationErrorCode is int
nAdditionErrorCode is int
sFileInfo is string
nFileIndex is int
 
// Create an archive
nCreationErrorCode = zipCreate(sArchiveName, "C:\Directory\Archives\ArchivePdf.zip")
 
IF nCreationErrorCode = 0 THEN
 
// Select the directory
sDirectoryName = fSelectDir("", "", "Directory to add")
// Add all the files found in the selected directory
// and subdirectories to the archive
nAdditionErrorCode = zipAddDirectory(sArchiveName, sDirectoryName, True, zipDirectory)
IF nAdditionErrorCode = 0 THEN
  // Select the file in the archive
  nFileSubscript = TableSelect(TABLE_ArchiveTable)
  // Returns information about the selected file
  sFileInfo = zipInfoFile(sArchiveName, nFileSubscript)
  // Display the information
  IF sFileInfo <> "" THEN
  Info("The file information is: " + sFileInfo)
  END
ELSE
  // Display an error message if the files have not been added
  Error(zipMsgError(nAdditionErrorCode))
  END
ELSE
// Display an error message if the archive was not created
Error(zipMsgError(nCreationErrorCode))
END
Example 2: Displaying information about a file found in an archive according to its path
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)Ajax The following code is used to display information about a file found in an archive. The file whose information is displayed is selected according to its stored path. The file information is stored in a memory Table control (TABLE_InfoTable).
// Declare and initialize the variables
sArchiveName is string = "MyArchive"
sDirectoryName is string
nCreationErrorCode is int
nAdditionErrorCode is int
sFileInfo is string
 
// Create an archive
nCreationErrorCode = zipCreate(sArchiveName, "C:\Directory\Archives\ArchivePdf.zip")
 
IF nCreationErrorCode = 0 THEN
// Select the directory
sDirectoryName = fSelectDir("", "", "Directory to add")
// Add all the files found in the selected directory
// and subdirectories to the archive
nAdditionErrorCode = zipAddDirectory(sArchiveName, sDirectoryName, True, zipDirectory)
IF nAdditionErrorCode = 0 THEN
// Returns information about a file
  sFileInfo = zipInfoFile(sArchiveName, "C:\Documents\File.txt")
  IF sFileInfo <> "" THEN
TableAdd(TABLE_InfoTable, sFileInfo)
  END
ELSE
  // Display an error message if the files have not been added
  Error(zipMsgError(nAdditionErrorCode))
END
ELSE
// Display an error message if the archive was not created
Error(zipMsgError(nCreationErrorCode))
END
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 04/06/2023

Send a report | Local help