ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Archive functions
  • Example 1: Deleting a file from the archive according to its subscript
  • Example 2: Deleting a file from the archive according to its stored path
zipDeleteFile (Example)
Example 1: Deleting a file from the archive according to its subscript
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)Ajax The following code is used to delete a file from an archive. The file to delete is selected in a memory Table control (TABLE_ArchiveTable). Caution: In order for the subscript of the memory Table control to correspond to the subscript of the selected file, the memory Table control must not be sorted.
// Declare and initialize the variables
DirectoryName is string
ArchiveName is string = "MyArchive"
CreationErrorCode is int
AdditionErrorCode is int
ErrorCodeDel is int
FileIndex is int
 
// Create an archive
CreationErrorCode = zipCreate(ArchiveName, "C:\Directory\Archives\ArchivePdf.zip")
 
// Create an archive (WINDEV Mobile)
CreationErrorCode = zipCreate(ArchiveName, "\Directory\Archives\ArchivePdf.zip")
 
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)
 // Delete the selected file
 ErrorCodeDel = zipDeleteFile(ArchiveName, FileSubscript)
IF ErrorCodeDel <> 0 THEN
Error(zipMsgError(ErrorCodeDel))
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: Deleting a file from the archive according to its stored path
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)Ajax The following code is used to delete a file from an archive. The file to delete is selected according to its stored path.
// Declare and initialize the variables
ArchiveName is string = "MyArchive"
DirectoryName is string
CreationErrorCode is int
AdditionErrorCode is int
ErrorCodeDel is int
 
// Create an archive
CreationErrorCode = zipCreate(ArchiveName, "C:\Directory\Archives\ArchivePdf.zip")
 
// Create an archive for WINDEV Mobile
CreationErrorCode = zipCreate(ArchiveName, "\Directory\Archives\ArchivePdf.zip")
 
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
// Delete a file
ErrorCodeDel = zipDeleteFile(ArchiveName, "Directory\File.txt")
IF ErrorCodeDel <> 0 THEN
Error(zipMsgError(ErrorCodeDel))
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
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