PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

  • 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 QueriesWindows MobileAjaxUser code (UMC) 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"
ErrorCodeCreation is int
ErrorCodeAddition is int
ErrorCodeDel is int
FileSubscript is int
 
// Create an archive
ErrorCodeCreation = zipCreate(ArchiveName, "C:\Directory\Archives\ArchivePdf.zip")
 
// Create an archive (WINDEV Mobile)
ErrorCodeCreation = zipCreate(ArchiveName, "\Directory\Archives\ArchivePdf.zip")
 
IF ErrorCodeCreation = 0 THEN
// Select the directory
DirectoryName = fSelectDir("", "", "Directory to add")
// Adds all the files found in the selected directory
// and in its sub-directories into the archive
ErrorCodeAddition = zipAddDirectory(ArchiveName, DirectoryName, True, zipDirectory)
IF ErrorCodeAddition = 0 THEN
 // Select the file in the archive
 FileSubscript = 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(ErrorCodeAddition))
END
ELSE
// Display an error message if the archive was not created
Error(zipMsgError(ErrorCodeCreation))
END
Example 2: Deleting a file from the archive according to its stored path
WINDEVWEBDEV - Server codeReports and QueriesWindows MobileAjaxUser code (UMC) 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
ErrorCodeCreation is int
ErrorCodeAddition is int
ErrorCodeDel is int
 
// Create an archive
ErrorCodeCreation = zipCreate(ArchiveName, "C:\Directory\Archives\ArchivePdf.zip")
 
// Create an archive for WINDEV Mobile
ErrorCodeCreation = zipCreate(ArchiveName, "\Directory\Archives\ArchivePdf.zip")
 
IF ErrorCodeCreation = 0 THEN
// Select the directory
DirectoryName = fSelectDir("", "", "Directory to add")
// Adds all the files found in the selected directory
// and in its sub-directories into the archive
ErrorCodeAddition = zipAddDirectory(ArchiveName, DirectoryName, True, zipDirectory)
IF ErrorCodeAddition = 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(ErrorCodeAddition))
  END
ELSE
// Display an error message if the archive was not created
Error(zipMsgError(ErrorCodeCreation))
END
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment