> 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/smb/writefile.md).

# WriteFile

Write file to SMB server.

Task version: 2.7.0

Required Frends version: 5.7+

Required .NET version: 8.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.Smb/tree/main/Frends.Smb.WriteFile>

## Task Parameters

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

| Name                       | Description                                                                                                                              |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| Content : `Byte[]`         | <p>Content of the file to be written.</p><p><br>Default: <code>-</code><br>Example: <code>\[1,2,3]</code></p>                            |
| DestinationPath : `String` | <p>Full path to the destination file we want to write to.</p><p><br>Default: <code>-</code><br>Example: <code>folder\file.txt</code></p> |
| {% endtab %}               |                                                                                                                                          |

{% tab title="Connection" %}

| Name                                      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Server : `String`                         | <p>SMB server address or hostname.</p><p><br>Default: <code>-</code><br>Example: <code>127.0.0.1</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| Share : `String`                          | <p>SMB share name to connect to.</p><p><br>Default: <code>-</code><br>Example: <code>testShare</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| Username : `String`                       | <p>Username for SMB authentication.</p><p>This needs to be of format domain\username</p><p><br>Default: <code>-</code><br>Example: <code>WORKGROUP\Administrator</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| 🗝Password : `String`                     | <p>Password for the SMB credentials.</p><p><br>Default: <code>-</code><br>Example: <code>Password123</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| OperatingSystem : `Os`                    | <p>Defines the operating system of the SMB server.</p><p>Options used to determine correct path separator to use.</p><p>Possible values:</p><ul><li><code>Windows</code>: Defines the operating system of the SMB server.</li></ul><p>Options used to determine correct path separator to use.</p><ul><li><code>Linux</code>: Defines the operating system of the SMB server.</li></ul><p>Options used to determine correct path separator to use.</p><p><br>Default: <code>Linux</code><br>Example: <code>Linux</code></p>                                                                                                                                                                                                                                                                                                                            |
| AuthenticationMode : `AuthenticationMode` | <p>Authentication mechanism to use when connecting to the SMB server.</p><p>Kerberos and KerberosTicketCache require network access to a KDC and a registered</p><p>SPN (cifs/servername) for the target server in Active Directory.</p><p>Possible values:</p><ul><li><code>Ntlm</code>: NTLM authentication protocol.</li><li><code>Kerberos</code>: Kerberos authentication protocol using username and password.</li></ul><p>Requires network access to a KDC and a registered SPN (cifs/servername)</p><p>for the target server in Active Directory.</p><ul><li><code>KerberosTicketCache</code>: Kerberos authentication protocol using a pre-existing ticket cache (ccache) file.</li></ul><p>Requires a valid TGT in the ccache file created externally e.g. via kinit.</p><p><br>Default: <code>Ntlm</code><br>Example: <code>Ntlm</code></p> |
| KerberosServerName : `String`             | <p>Hostname used to build the Kerberos SPN (cifs/hostname) when AuthenticationMode is Kerberos.</p><p>Falls back to Server when not set. Only needed when the address used for the TCP</p><p>connection differs from the server's registered Kerberos identity - e.g.</p><p>where you connect via a mapped IP/port but the AD-registered name is something else.</p><p><br>Default: <code>-</code><br>Example: <code>DC1.test.local</code></p>                                                                                                                                                                                                                                                                                                                                                                                                         |
| KdcAddress : `String`                     | <p>Optional explicit KDC address (host or host:port) for Kerberos authentication.</p><p>Use when DNS SRV discovery is unavailable.</p><p>If empty, KDC will be discovered via DNS SRV records for the realm.</p><p><br>Default: <code>-</code><br>Example: <code>kdc.company.com:88</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| KerberosCacheFile : `String`              | <p>Path to a Kerberos ticket cache (ccache) file to use for authentication when</p><p>AuthenticationMode is KerberosTicketCache. The file must already contain a valid</p><p>ticket-granting ticket (e.g. created via kinit).</p><p><br>Default: <code>-</code><br>Example: <code>/tmp/krb5cc\_testuser</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| {% endtab %}                              |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |

{% tab title="Options" %}

| Name                             | Description                                                                                                                     |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| Overwrite : `Boolean`            | <p>Whether to overwrite the file if it already exists.</p><p><br>Default: <code>False</code><br>Example: <code>false</code></p> |
| 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.</p><p><br>Default: <code>-</code><br>Example: <code>Custom error message</code></p>  |
| {% endtab %}                     |                                                                                                                                 |
| {% endtabs %}                    |                                                                                                                                 |

## Task Result

| Name                               | Description                                                                                                                    |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| Success : `Boolean`                | <p>Indicates if the task completed successfully.<br>Example: <code>true</code></p>                                             |
| Path : `PathString`                | <p>Full path to the written file.<br>Example: <code>\server\share\dir\file.txt</code></p>                                      |
| Path.Value : `String`              | <p>Gets or sets the normalized path value.<br>Example: <code>folder\file.txt</code></p>                                        |
| SizeInMegaBytes : `Double`         | <p>Size of the written file in megabytes.<br>Example: <code>32</code></p>                                                      |
| Error : `Error`                    | <p>Error that occurred during task execution.<br>Example: <code>object { string Message, Exception AdditionalInfo }</code></p> |
| Error.Message : `String`           | <p>Summary of the error.<br>Example: <code>Unable to join strings.</code></p>                                                  |
| Error.AdditionalInfo : `Exception` | <p>Additional information about the error.<br>Example: <code>object { Exception AdditionalInfo }</code></p>                    |

## Task Changelog

Changelog for Task Frends.Smb.WriteFile.

### \[2.7.0] - 2026-09-30

#### Changed

* Updated package copyright metadata to meet Frends compliance requirements.

### \[2.6.0] - 2026-09-25

#### Added

* Added new `KerberosTicketCache` authentication mode supporting Kerberos authentication using a pre-existing ticket cache (ccache) file.

#### Fixed

* Kerberos authentication now correctly truncates the session key to 16 bytes as required by the SMB specification.

### \[2.5.0] - 2026-09-09

#### Fixed

* Adjusted access permissions to prevent sharing violations for directories and added synchronous I/O flags to file creation.

### \[2.4.0] - 2026-07-27

#### Added

* Added Kerberos authentication support for SMB connections
  * New `Connection.AuthenticationMode` property with `Ntlm` (default) and `Kerberos` options
  * New `Connection.KerberosServerName` property for specifying the Kerberos SPN hostname when it differs from the TCP connection address
  * New `Connection.KdcAddress` property for explicit KDC address when DNS SRV discovery is unavailable
  * `KerberosNetAuthenticationClient` internally handles TGT acquisition, service ticket retrieval, and GSS-API token generation using the Kerberos.NET library

### \[2.3.0] - 2026-07-20

#### Fixed

* Optimized SMB file handling: fixed lingering locks and adjusted access permissions to prevent sharing violations.

### \[2.2.0] - 2026-06-26

#### Changed

* Username parsing: now accepts a username without a domain instead of throwing an error.
* Server connection: removed manual DNS resolve; connects using the raw server address string.

### \[2.1.0] - 2026-04-23

#### Fixed

* Input parameters treated as normal string instead of PathString type.

### \[2.0.0] - 2026-04-08

#### Added

* New connection parameters that defined what servers Operating System.
* \[Breaking Change] Introduce PathString type that will represent paths with OS specific separators.

### \[1.0.0] - 2025-10-31

#### 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/smb/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.
