Adds a file to a compressed zip archive.
Syntax: |
---|
DlxFile.AddFile(file, name) DlxFile.AddFile(filepath) DlxFile.AddFile(filepath, name) |
Parameters
Parameter | Description |
---|---|
file | The DlxFile to be added to the compressed zip archive. |
filepath | Relative or full path to a file to add to the compressed zip archive. |
name | Name with which the file must be stored in the compressed zip archive. If not specified, the file name is used. |
Return Value
If the operation ends correctly it returns true otherwise it returns false.
Remarks
If a full path is not specified, each file path is considered relative to the user's workbook. For example, the relative path "myscripts\firstscript.clxjs" is changed to the full path "c:\....\documents\alterlogix\drawlogix\myscripts\firstscript.clxjs".
Example
Copy code | |
---|---|
var file = new DlxFile("www.mysite/files/myfile.pdf", DlxApp.FILEOPEN_READBINARY);
if (file.IsValid())
{
var zip = new DlxFile("demo.zip", DlxApp.FILEOPEN_ZIP);
zip.AddFile(file, "demo.bin");
zip.AddText("demo1.txt", "Text file demo 1.");
zip.AddFolder("folder1");
zip.AddText("folder1/demo2.txt", "Text file demo 2.");
zip.Close();
};
|