> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kasoftware.com/llms.txt
> Use this file to discover all available pages before exploring further.

# zipCompress

> 將檔案或資料夾壓縮為 ZIP、TAR、JAR 或 GZIP 存檔。

export const siteNameShort = "知行之橋";

將檔案或資料夾壓縮到存檔中。要壓縮單個檔案，請使用 `includefile#`。要壓縮資料夾，請使用 `includefolder#`。

## 必需的參數

* **type**: 存檔的型別。允許的值為 ZIP、TAR、JAR 和 GZIP。預設值為 ZIP。
* **archive**: 磁碟上的路徑（包括檔名），運算器應將存檔放置在此處。
* **includefile#**: 要包含在存檔中的檔案陣列。例如，要歸檔兩個檔案，請在 `includefile#1` 和 `includefile#2` 中將檔案路徑設定為這些檔案。有關 ArcScript 中陣列屬性的更多資訊，請參閱 [ArcScript 簡介](./operations)。
* **includefolder#**: 要包含在存檔中的資料夾陣列。例如，要歸檔兩個資料夾，請在 `includefolder#1` 和 `includefolder#2` 中將檔案路徑設定為這些資料夾。

## 可選的參數

* **manifest**: 清單檔案的位置。僅對 JAR 存檔有效。

## 輸出屬性

* **zip:result**: 如果運算器成功，將傳回 SUCCESS。

## 範例

此範例壓縮兩個資料夾（`/tmp/foo` 和 `/tmp/bar`），並將它們放入位於 `/home/mydata.gzip` 的 gzip 存檔中。

```xml theme={null}
<!-- Creating the input item and the necessary attributes -->
<arc:set attr="zip.archive" value="/home/mydata.gzip" />
<arc:set attr="zip.type" value="GZIP" />
<arc:set attr="zip.includefolder#1" value="/tmp/foo" />
<arc:set attr="zip.includefolder#2" value="/tmp/bar" />

<arc:call op="zipCompress" in="zip">
  <!-- Optional logging step to log the status of the operation to the application log. -->
  <arc:set attr="_log.info" value="The zipCompress operation for connector [ConnectorId] has finished with a status of [results.zip:result]." />
</arc:call>
```
