|
ZipFile() 
Compress a file using a ZIP compatible file
compression format.
Syntax
ZipFile(<acFile>, <cZip>,
[nCompression], [cPassWord]) --> cResult
Arguments
<acFile> --> The path and file name of
the file to zip compress or an array of file paths and names. You
must specify the full path location of the file or files.
It is risky to attempt to zip a file or files that may
be open.
<cZip> --> The
path and file name of the zip file to create. You must specify the
fill destination path. If a file extension is not specified the
default file extension becomes .ZIP
<nCompression> The
compression mode to use. The default value if not specified is 2.
Options are listed in the following table:
|
Value
|
Description
|
|
0
|
No
compression.
|
|
1
|
Low
compression.
|
|
2
|
Normal
compression.
|
|
3
|
Maximum
compression.
|
<cPassWord> An
optional password may be included to encrypt and password protect
the ZIP file.
Returns
This function returns an
empty string if the operation was successful, otherwise a
description of the error is returned.
Description
This function can be used
to compress a file so that it occupies less physical disk space.
This can be particularly useful when transferring files over the
Internet. The resulting file is given the file extension .ZIP if an
extension is not specified. The file can be decompressed (unzipped)
using third-party zip compression software such as PKZIP, Winzip
and others.
Notes
A zip file
cannot be created if it already exists at the path specified. You
should confirm the existence of the file and delete it (if
necessary) before invoking the ZipFile() function.
Example #1
Declare ZipMsg Type Character
ZipMsg := ZipFile("c:\capital\report.txt",
"c:\capital\report.zip")
* Was there a problem?
If .Not. IsEmpty(ZipMsg)
Echo(ZipMsg,, TRUE)
Endif
Example #2
* Zip & Email A Card File With
a Password
Declare cEmail Type
Character
cEmail := ""
FormCreate()
FormAdd("Email To", 1, { "Tom",
"Dick", "Harry" } )
FormShow("Email CARD
FILE")
If FormResult(1) ==
1
cEmail :=
"tom@mycompany.com"
Endif
If FormResult(1) ==
2
cEmail :=
"dick@mycompany.com"
Endif
If FormResult(1) ==
3
cEmail :=
"harry@mycompany.com"
Endif
If .Not.
IsEmpty(cEmail)
If
IsEmpty(ZipFile(PathCompany() + "CARD1.*", PathProgram() + "CARD1",
3, "UGHDFGS173"))
AddMail(cEmail,
"CARDFILE Transfer", "", PathProgram() + "CARD1.ZIP")
SendMail()
Endif
Endif
____________________________
Related Topics
Business
Function List
|