Xbasic

FILE.ZIP Function

Syntax

Result_Flag as L = FILE.Zip(C zipfilename,C files[,C zip_flags[,C base_path]])

Arguments

zipfilenameCharacter

The name of the zip file to create. If you do not specify an extension, Alpha Anywhere will automatically add the ".ZIP" extension.

filesCharacter

Files to add to the zip file. Wildcards are allowed (e.g. " c:\Alpha Anywhere\data\invoices\*.* "). Otherwise, provide a comma, or CR-LF delimited list of file names. If you provide a CR-LF delimited list, you must add ',' to the list of flags.

zip_flagsCharacter

Default = "" (No paths are stored.) The following flags can be used in the zip command:

Flag
Meaning
"d"

Include absolute paths in the zip file.

"base path"

Store paths in the zip file that are relative to the base path.

","

Indicate that the list of files is CR-LF delimited, not comma delimited. Use this flag if there are commas in any of the filenames.

base_pathCharacter

The base path to store in the zip file.

Returns

Result_FlagLogical

Returns .T. if the zip file was successfully created, otherwise .F.

Description

Zip files listed - expects a comma separated list.

Discussion

The FILE.ZIP() method adds a file or files to a zip file called Zip_Filename. If Zip_Filename does not exists it is created. If Zip_Filename already exists, then the files in the File_List are added to the existing zip file. File_List can include wildcard characters.

A zip file is a highly compressed files that contains one or more files. Zip files are ideal for creating backups of your database applications.

Example

For example, the following flag string specifies that the zip file should contain paths that are relative to the "c:\mydata" folder:

FILE.zip(myzip,"c:\mydata\*.*" ,"d","c:\mydata")

Example create a zip file of all of the files in c:\a5data\invoice.

FILE.ZIP("c:\backup.ZIP","c:\a5data\invoice\*.*")

Example create a zip file of all of the files in the current database folder.

path = :a5.get_path()
zip_filename = "backup_data"
'construct full filename - chr(92) is \ character.
full_zip_filename = alltrim(path) + chr(92) + zip_filename
'Check to see if zip file exists. If it does, delete it.
If FILE.exists(full_zip_filename ) then
    FILE.remove(full_zip_filename)
End if
FILE.zip(full_zip_filename,path + chr(92) + "*.*")
FILE.ZIP does not support creating password protected zip archives.

See Also