ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Archive functions
  • Use conditions
  • Error codes
  • Index of files in the archive
  • Stored path
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Deletes a file from an archive.
Example
Reports and Queries
MonArchive is zipArchive
// Création de l'archive
ResOuverture = MonArchive.Open("C:\Temp\Archive.zip")
IF ResOuverture = 0 THEN
...
	// Suppression de "Fichier.doc"
	ResSuppression = MonArchive.DeleteFile("Fichier.doc")
...
END
Syntax

Deleting a file using its index Hide the details

<Result> = <Archive>.DeleteFile(<File index>)
<Result>: Integer
  • 0 if the file was deleted,
  • An error code (value greater than 0) otherwise. The message corresponding to the error code is returned by zipMsgError.
<Archive>: zipArchive variable
Name of a variable of type zipArchive corresponding to the archive to use.
<File index>: Integer
Index of the file to be deleted from the archive. <zipArchive variable>.FindFile returns this index.

Deleting a file according to its path Hide the details

<Result> = <Archive name>.DeleteFile(<File path>)
<Result>: Integer
  • 0 if the file was deleted,
  • An error code (value greater than 0) otherwise. The message corresponding to the error code is returned by zipMsgError.
<Archive name>: zipArchive variable
Name of a variable of type zipArchive corresponding to the archive to use.
<File path>: Character string
Stored path of the file that must be deleted from the archive.
Remarks

Use conditions

The files can be deleted from an archive if:
  • The archive exists (archives are created using <zipArchive variable>.Create).
  • The archive is accessible in read/write.
  • The archive is a single-part archive.
Caution:
  • Archives in RAR format: This function is not available.
  • Archives in CAB format: This function is not available.
  • Archives in TAR or TGZ format (TAR.GZ): This function is not available.
  • Archives in 7z format: The archive is fully compressed each time the function is called <zipArchive variable>.DeleteFile. This function is recommended when deleting a single file. If several files must be deleted from the archive, use <zipArchive variable>.DeleteFileList.
Reminder:

    Error codes

    The following error codes are returned:
    • 2: Access denied: user does not have sufficient rights.
    • 3: The archive is corrupt.
    • 4: The path does not exist in the archive.
    • 5: Unable to write to archive.

    Index of files in the archive

    When a file is added into an archive, an index is automatically assigned to the file. This index corresponds to the order in which the files are included in the archive.
    To select a file in the archive, you can use:
    Important: After file deletion, files in an archive are re-indexed.. The indexes of the files after the deleted file are automatically decremented by 1.

    Stored path

    The table below presents the paths stored in the archive according to:
    • the access path to the file,
    • the path section to store.
    The current directory is: "C:\Temp".
    zipAddFileFile locationzipNonezipDirectoryzipDrive
    zipAddFile("Archi",
    "File.txt")
    C:\Temp\File.txtFile.txtFile.txtFile.txt
    zipAddFile("Archi",
    "Data\File.txt")
    C:\Temp\Data\File.txtFile.txtData\File.txtData\File.txt
    zipAddFile("Archi",
    "D:\Data\File.txt")
    D:\Data\File.txtFile.txtData\File.txtD:\Data\File.txt

    Remark: If the constant zipDisk is used, WDZ format memorizes the full path of the file (including drive letter), whereas ZIP format does not memorize the drive letter.
    Component: wd300zip.dll
    Minimum version required
    • Version 24
    This page is also available for…
    Comments
    Click [Add] to post a comment

    Last update: 09/26/2024

    Send a report | Local help