# CreateArchive

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.ZIP/tree/main/Frends.Zip.CreateArchive>

{% tabs %}
{% tab title="Parameter: SourceProperties" %}

| Name                           | Description                                                                                                                                                                                                                                                                                                                                              |
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| SourceType : `SourceFilesType` | <p>Source files input type.</p><p>Possible values:</p><ul><li><code>PathAndFileMask</code>:</li></ul><p>Source files input type.</p><ul><li><code>FileList</code>:</li></ul><p>Source files input type.</p><p><br>Default: <code>0</code><br>Example: <code>PathAndFileMask</code></p>                                                                   |
| Directory : `String`           | <p>Source directory.</p><p><br>Default: <code>-</code><br>Example: <code>C:\example\folder\</code></code></p>                                                                                                                                                                                                                                            |
| FileMask : `String`            | <p>The search string to match against the names of files.</p><p>This parameter can contain a combination of valid literal path and wildcard (\* and ?) characters (see Remarks), but doesn't support regular expressions.</p><p>The default pattern is "<em>", which returns all files.</em></p><p><br><em>Default:</em><br>Example: <code>\*</code></p> |
| IncludeSubFolders : `Boolean`  | <p>Indicates if subfolders and files should also be zipped.</p><p><br>Default: <code>False</code><br>Example: <code>false</code></p>                                                                                                                                                                                                                     |
| FlattenFolders : `Boolean`     | <p>Choose if source folder structure should be flatten when zipped.</p><p><br>Default: <code>False</code><br>Example: <code>false</code></p>                                                                                                                                                                                                             |
| FilePathsList : `List<String>` | <p>List of full file paths to include in zip.</p><p><br>Default: <code>-</code><br>Example: <code>new List { Directory.GetFiles(\_dir, "\*.txt")\[0] };</code></p>                                                                                                                                                                                       |
| RemoveZippedFiles : `Boolean`  | <p>If true, files added to the zip are removed from source directory.</p><p><br>Default: <code>False</code><br>Example: <code>false</code></p>                                                                                                                                                                                                           |
| {% endtab %}                   |                                                                                                                                                                                                                                                                                                                                                          |

{% tab title="Parameter: DestinationProperties" %}

| Name                             | Description                                                                                                                                                                                                                                 |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Directory : `String`             | <p>Destination directory.</p><p><br>Default: <code>-</code><br>Example: <code>c:\temp</code></p>                                                                                                                                            |
| FileName : `String`              | <p>Filename of the zip to create.</p><p><br>Default: <code>-</code><br>Example: <code>sample.zip</code></p>                                                                                                                                 |
| 🗝Password : `String`            | <p>Add password protection to zip.</p><p><br>Default: <code>-</code><br>Example: <code>foobar123</code></p>                                                                                                                                 |
| RenameDuplicateFiles : `Boolean` | <p>True: If source files contains duplicate names, they are renamed (example.txt --> example\_(1).txt).</p><p>False: Throws error if duplicate file names are found.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p> |
| {% endtab %}                     |                                                                                                                                                                                                                                             |

{% tab title="Parameter: Options" %}

| Name                                            | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| UseZip64 : `UseZip64Option`                     | <p>Always: Always use ZIP64 extensions when writing zip archives, even when unnecessary.</p><p>AsNecessary: Use ZIP64 extensions when writing zip archives, as necessary (when single entry or entries in total exceeds 0xFFFFFFFF in size, or when there are more than 65535 entries).</p><p>Never: Do not use ZIP64 extensions when writing zip archives.</p><p>Possible values:</p><ul><li><code>Always</code>:</li></ul><p>Always: Always use ZIP64 extensions when writing zip archives, even when unnecessary.</p><p>AsNecessary: Use ZIP64 extensions when writing zip archives, as necessary (when single entry or entries in total exceeds 0xFFFFFFFF in size, or when there are more than 65535 entries).</p><p>Never: Do not use ZIP64 extensions when writing zip archives.</p><ul><li><code>AsNecessary</code>:</li></ul><p>Always: Always use ZIP64 extensions when writing zip archives, even when unnecessary.</p><p>AsNecessary: Use ZIP64 extensions when writing zip archives, as necessary (when single entry or entries in total exceeds 0xFFFFFFFF in size, or when there are more than 65535 entries).</p><p>Never: Do not use ZIP64 extensions when writing zip archives.</p><ul><li><code>Never</code>:</li></ul><p>Always: Always use ZIP64 extensions when writing zip archives, even when unnecessary.</p><p>AsNecessary: Use ZIP64 extensions when writing zip archives, as necessary (when single entry or entries in total exceeds 0xFFFFFFFF in size, or when there are more than 65535 entries).</p><p>Never: Do not use ZIP64 extensions when writing zip archives.</p><p><br>Default: <code>1</code><br>Example: <code>AsNecessary</code></p>                                                                                                                                    |
| Encoding : `FileEncoding`                       | <p>Encoding for file and directory names.</p><p>Possible values:</p><ul><li><code>UTF8</code>:</li></ul><p>Encoding for file and directory names.</p><ul><li><code>ANSI</code>:</li></ul><p>Encoding for file and directory names.</p><ul><li><code>ASCII</code>:</li></ul><p>Encoding for file and directory names.</p><ul><li><code>WINDOWS1252</code>:</li></ul><p>Encoding for file and directory names.</p><ul><li><code>Other</code>:</li></ul><p>Encoding for file and directory names.</p><p><br>Default: <code>-</code><br>Example: <code>Encoding.UTF8</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| EnableBom : `Boolean`                           | <p>Additional option for UTF-8 encoding to enable bom.</p><p><br>Default: <code>-</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| EncodingInString : `String`                     | <p>File encoding to be used. A partial list of possible encodings: <https://en.wikipedia.org/wiki/Windows_code_page#List>.</p><p><br>Default: <code>-</code><br>Example: <code>utf-8</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ThrowErrorIfNoFilesFound : `Boolean`            | <p>Throw error if no source files are found. Otherwise returns object with FileCount: 0.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| DestinationFileExistsAction : `FileExistAction` | <p>Choose action if destination zip file already exists.</p><p>Error: throws error.</p><p>Overwrite: Overwrites existing zip file with new one.</p><p>Rename: Renames new zip file (example.zip --> example\_(1).zip).</p><p>Append: Adds new files to zip, if file already exists in zip, it is renamed.</p><p>Possible values:</p><ul><li><code>Error</code>:</li></ul><p>Choose action if destination zip file already exists.</p><p>Error: throws error.</p><p>Overwrite: Overwrites existing zip file with new one.</p><p>Rename: Renames new zip file (example.zip --> example\_(1).zip).</p><p>Append: Adds new files to zip, if file already exists in zip, it is renamed.</p><ul><li><code>Append</code>:</li></ul><p>Choose action if destination zip file already exists.</p><p>Error: throws error.</p><p>Overwrite: Overwrites existing zip file with new one.</p><p>Rename: Renames new zip file (example.zip --> example\_(1).zip).</p><p>Append: Adds new files to zip, if file already exists in zip, it is renamed.</p><ul><li><code>Overwrite</code>:</li></ul><p>Choose action if destination zip file already exists.</p><p>Error: throws error.</p><p>Overwrite: Overwrites existing zip file with new one.</p><p>Rename: Renames new zip file (example.zip --> example\_(1).zip).</p><p>Append: Adds new files to zip, if file already exists in zip, it is renamed.</p><ul><li><code>Rename</code>:</li></ul><p>Choose action if destination zip file already exists.</p><p>Error: throws error.</p><p>Overwrite: Overwrites existing zip file with new one.</p><p>Rename: Renames new zip file (example.zip --> example\_(1).zip).</p><p>Append: Adds new files to zip, if file already exists in zip, it is renamed.</p><p><br>Default: <code>0</code><br>Example: <code>Error</code></p> |
| CreateDestinationFolder : `Boolean`             | <p>Create destination folder if it does not exist.</p><p><br>Default: <code>False</code><br>Example: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| {% endtab %}                                    |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |

{% tab title="Result: Result" %}

| Name                           | Description                                                                       |
| ------------------------------ | --------------------------------------------------------------------------------- |
| Path : `String`                | <p>Full path to zip created.<br>Example: <code>c:\temp\zip\_sample.zip</code></p> |
| FileCount : `Int32`            | <p>Number of files in created zip file.<br>Example: <code>1</code></p>            |
| ArchivedFiles : `List<String>` | <p>List of files zipped.<br>Example: <code>TestFile.txt, TestFile2.txt</code></p> |
| {% endtab %}                   |                                                                                   |

{% tab title="Changelog" %}

## Changelog

### \[1.3.0] - 2025-12-29

#### Fixed

* Fix repository url in metadata

### \[1.2.0] - 2024-12-13

#### Changed

* Drop DotNetZip in favour of ProDotNetZip because of security reasons
* DotNetZip has a HIGH severity directory traversal vulnerability (CVE reported Nov 2024) affecting versions 1.10.1 through 1.16.0 with no patch available (package is deprecated)
* The migration to ProDotNetZip 1.20.0 addresses this security concern

### \[1.1.0] - 2023-11-27

#### Added

* \[Breaking] Added Encoding for file and directory names.

### \[1.0.0] - 2022-02-23

#### Added

* Initial implementation
  {% endtab %}
  {% endtabs %}
