wwZipArchive::AppendFiles

Appends files to an existing zip file or creates a new zip file if it doesn't exist.

This method is identical to the ZipFiles() function except it optionally appends files to an existing zip file while ZipFiles() first deletes the file.

AppendFiles(lcZipFile,lcFiles,
            lcBaseFolder, llRecurse,
            llFast)

Return Value

.T. or .F. - check cErrorMsg for error

Parameters

lcZipFile
The Zip file to append to or create if it doesn't exist

lcFiles
Files or file specs to include as a comma delimited list

  • Full path - c:\temp\test.prg or c:\temp*.prg
  • Relative Path - test.prg or *.prg,*.h The relative path behavoir depends on whether lcBaseFolder is provided or not. If provides the path is relative to the lcBaseFolder. If not provided the path is resolved using the current path and FoxPro path.
  • FileSpec - *.prg,*.md

lcBaseFolder
Required if you want your zip file to have a folder structure. If provided any relative file paths provided in lcFiles are relative to the base folder. If not provided, any partial paths are relative to the current path.

Note: You can add partial paths and wildcards that are associated with the base folder, and also add additional files using other fully qualified files. These other paths are added to the archive as folders prefixed with __.

Scenarios:

  • No lcBasePath - files are added without folder structure in the zip
  • lcBasePath set, relative paths only- all files are added using zip folder structure
  • lcBasePath set, full paths - Paths that are relative to base path are added using zip folder structure, others are added with __

llRecurse
Optional - if .T. the directory where the filespec is applied is recursed. Default is .F.

llFast
Optional - if .t. optimize for performance, if .f. optimize for size. Default .F.

Remarks

  • This is a standalone function not a method of the wwApi class
  • Depends on wwDotnetBridge and requires distribution of wwDotnetBridge.dll

Example

loZip = CREATEOBJECT("wwZipArchive")

? loZip.AppendFiles(;
   "d:\temp\zipfiles.zip",;
   "config.fpw,*.prg,*.dll,*.h",;
   CURDIR(),.T.)

loZip.UnzipFolder("d:\temp\zipfiles.zip","d:\temp\unzipped")

See also:

Class wwApi | wwZipArchive::UnzipFolder | wwZipArchive::AppendFiles

© West Wind Technologies, 1996-2024 • Updated: 06/05/24
Comment or report problem with topic