> For the complete documentation index, see [llms.txt](https://docs.frends.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.frends.com/tasks/tasks/ftp/writefile.md).

# WriteFile

Writes file to the FTPS server.

Task version: 1.2.0

Required Frends version: 5.7+

Required .NET version: 8.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.FTP>

## Task Parameters

{% tabs %}
{% tab title="Input" %}

| Name                                     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Path : `String`                          | <p>Full path for the file to be written.</p><p><br>Default: <code>-</code><br>Example: <code>/ , /SubDir/test.txt</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| Content : `String`                       | <p>Text content to be written.</p><p><br>Default: <code>-</code><br>Example: <code>This is test file</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| CreateDestinationDirectories : `Boolean` | <p>Enables Task to create destination directories if they don't exist.</p><p><br>Default: <code>False</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| FileEncoding : `FileEncoding`            | <p>If set, this ecoding will be used to encode and decode command</p><p>parameters and server responses, such as file names.</p><p>By selecting 'Other' you can use any encoding.</p><p>Possible values:</p><ul><li><code>UTF8</code>: If set, this ecoding will be used to encode and decode command</li></ul><p>parameters and server responses, such as file names.</p><p>By selecting 'Other' you can use any encoding.</p><ul><li><code>ANSI</code>: If set, this ecoding will be used to encode and decode command</li></ul><p>parameters and server responses, such as file names.</p><p>By selecting 'Other' you can use any encoding.</p><ul><li><code>ASCII</code>: If set, this ecoding will be used to encode and decode command</li></ul><p>parameters and server responses, such as file names.</p><p>By selecting 'Other' you can use any encoding.</p><ul><li><code>WINDOWS1252</code>: If set, this ecoding will be used to encode and decode command</li></ul><p>parameters and server responses, such as file names.</p><p>By selecting 'Other' you can use any encoding.</p><ul><li><code>Other</code>: Other enables users to add other encoding options as string.</li></ul><p><br>Default: <code>ANSI</code><br>Example: <code>FileEncoding.ANSI</code></p> |
| EnableBom : `Boolean`                    | <p>Additional option for UTF-8 encoding to enable bom.</p><p><br>Default: <code>False</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| EncodingInString : `String`              | <p>File encoding to be used.</p><p>Encoding don't support any unicode encoding. It only support the code page encodings.</p><p>A partial list of possible encodings: <https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding.getencodings?view=net-6.0#examples>.</p><p><br>Default: <code>-</code><br>Example: <code>iso-8859-1</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| WriteBehaviour : `WriteOperation`        | <p>How the file write should work if a file with the new name already exists.</p><p>Possible values:</p><ul><li><code>Append</code>: How the file write should work if a file with the new name already exists.</li><li><code>Overwrite</code>: How the file write should work if a file with the new name already exists.</li><li><code>Error</code>: How the file write should work if a file with the new name already exists.</li></ul><p><br>Default: <code>-</code><br>Example: <code>WriteOperation.Append</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| AddNewLine : `Boolean`                   | <p>If enabled new line is added to the existing file before appending the content.</p><p><br>Default: <code>False</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| {% endtab %}                             |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |

{% tab title="Connection" %}

| Name                                  | Description                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Address : `String`                    | <p>FTP(S) host address</p><p><br>Default: <code>-</code><br>Example: <code>my.ftp.server.com</code></p>                                                                                                                                                                                                                                                                                                                                  |
| Port : `Int32`                        | <p>Port number to use in the connection to the server.</p><p><br>Default: <code>21</code><br>Example: <code>21</code></p>                                                                                                                                                                                                                                                                                                                |
| UserName : `String`                   | <p>Username to use for authentication to the server. Note that the file endpoint only supports</p><p>username for remote shares and the username must be in the format DOMAIN\Username.</p><p><br>Default: <code>-</code><br>Example: <code>myUsername</code></p>                                                                                                                                                                        |
| 🗝Password : `String`                 | <p>Password to use in the authentication to the server.</p><p><br>Default: <code>-</code><br>Example: <code>myPassword</code></p>                                                                                                                                                                                                                                                                                                        |
| TransportType : `FtpTransportType`    | <p>Type of transfer: 'Ascii' sends files as text and must only be used for sending ASCII text files. 'Binary' (default) sends files as raw data and should be used for sending e.g. UTF-encoded text files</p><p>Possible values:</p><ul><li><code>Binary</code>: Binary transport.</li><li><code>Ascii</code>: ASCII transport.</li></ul><p><br>Default: <code>Binary</code><br>Example: <code>FtpTransportType.Binary</code></p>       |
| Mode : `FtpMode`                      | <p>Connection mode to use to connect to the FTP server</p><p>Possible values:</p><ul><li><code>Passive</code>: Passive mode</li><li><code>Active</code>: Active mode.</li></ul><p><br>Default: <code>Passive</code><br>Example: <code>FtpMode.Passive</code></p>                                                                                                                                                                         |
| KeepConnectionAliveInterval : `Int32` | <p>Sends NOOP command to keep connection alive at specified time-interval in seconds. If set to 0 the connection is not kept alive. Default value is 0</p><p><br>Default: <code>0</code><br>Example: <code>60</code></p>                                                                                                                                                                                                                 |
| ConnectionTimeout : `Int32`           | <p>The length of time, in seconds, until the connection times out. You can use value 0 to indicate that the connection does not time out. Default value is 60 seconds</p><p><br>Default: <code>60</code><br>Example: <code>60</code></p>                                                                                                                                                                                                 |
| Encoding : `String`                   | <p>If set, this encoding will be used to encode and decode command parameters and server responses, such as file names. Example values: utf-8, utf-16, windows-1252</p><p><br>Default: <code>-</code><br>Example: <code>utf-8</code></p>                                                                                                                                                                                                 |
| BufferSize : `Int32`                  | <p>Integer value of used buffer size as bytes.</p><p>Default value is 4 KB.</p><p><br>Default: <code>4096</code><br>Example: <code>4096</code></p>                                                                                                                                                                                                                                                                                       |
| UseFTPS : `Boolean`                   | <p>Whether to use FTPS or not.</p><p><br>Default: <code>False</code><br>Example: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                  |
| SecureDataChannel : `Boolean`         | <p>Whether the data channel is secured or not.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                    |
| SslMode : `FtpsSslMode`               | <p>Specifies whether to use Explicit or Implicit SSL</p><p>Possible values:</p><ul><li><code>None</code>: No encryption (plain text).</li><li><code>Explicit</code>: Use explicit encryption.</li><li><code>Implicit</code>: Use implicit encryption.</li><li><code>Auto</code>: Tries to use FTPS encryption and falls back to plain text FTP.</li></ul><p><br>Default: <code>None</code><br>Example: <code>FtpsSslMode.None</code></p> |
| EnableClientAuth : `Boolean`          | <p>If enabled the client certificate is searched from user's certificate store</p><p><br>Default: <code>False</code><br>Example: <code>false</code></p>                                                                                                                                                                                                                                                                                  |
| ValidateAnyCertificate : `Boolean`    | <p>If enabled the any certificate will be considered valid.</p><p><br>Default: <code>False</code><br>Example: <code>false</code></p>                                                                                                                                                                                                                                                                                                     |
| ClientCertificatePath : `String`      | <p>Path to client certificate (X509).</p><p><br>Default: <code>-</code><br>Example: <code>c:\example.cer</code></p>                                                                                                                                                                                                                                                                                                                      |
| CertificateHashStringSHA1 : `String`  | <p>Certificate SHA1 hash string to validate against.</p><p><br>Default: <code>-</code><br>Example: <code>D911262984DE9CC32A3518A1094CD24249EA5C49</code></p>                                                                                                                                                                                                                                                                             |
| {% endtab %}                          |                                                                                                                                                                                                                                                                                                                                                                                                                                          |

{% tab title="Options" %}

| Name                             | Description                                                                                                                                                                                                                                                                                              |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ThrowErrorOnFailure : `Boolean`  | <p>Whether to throw an error on failure.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                                                                                                                          |
| ErrorMessageOnFailure : `String` | <p>Overrides the error message on failure. If <code>ThrowErrorOnFailure</code> is set to <code>true</code>, then the original exception will be wrapped in a new Exception with this error message.</p><p><br>Default: <code>-</code><br>Example: <code>Writing file to the FTP server failed</code></p> |
| {% endtab %}                     |                                                                                                                                                                                                                                                                                                          |
| {% endtabs %}                    |                                                                                                                                                                                                                                                                                                          |

## Task Result

| Name                               | Description                                                                                                         |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| Success : `Boolean`                | <p>Indicates whether the operation completed successfully.<br>Example: <code>true</code></p>                        |
| Path : `String`                    | <p>Full path to the written file. Null when Success is false.<br>Example: <code>/destination/newfile.txt</code></p> |
| SizeInMegaBytes : `Double`         | <p>Size of the new file in destination. Zero when Success is false.<br>Example: <code>3.2</code></p>                |
| Error : `Error`                    | <p>Error details. Null when Success is true.<br>Example: <code>null</code></p>                                      |
| Error.Message : `String`           | <p>Summary of the error.<br>Example: <code>Unable to connect to the FTP server</code></p>                           |
| Error.AdditionalInfo : `Exception` | <p>The exception that caused the error.<br>Example: <code>object { Exception AdditionalInfo }</code></p>            |

## Task Changelog

Changelog for Task Frends.FTP.WriteFile.

### \[1.2.0] - 2026-10-15

#### Changed

* The Task now targets .NET 8 only.
* Task parameters are now in the order Input, Connection, Options.
* The result now includes `Success` and `Error` properties.

#### Added

* Added `Options` with `ThrowErrorOnFailure` and `ErrorMessageOnFailure` to control whether failures throw an error or are returned in the result.

### \[1.1.0] - 2024-08-23

#### Changed

* Updated the Newtonsoft.Json package to version 13.0.3.

### \[1.0.0] - 2023-08-03

#### Added

* Initial implementation


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.frends.com/tasks/tasks/ftp/writefile.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
