> 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/files/writebytes.md).

# WriteBytes

Write file in bytes.

Task version: 1.1.0

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.Files/tree/main/Frends.Files.WriteBytes>

## Task Parameters

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

| Name                    | Description                                                                                                                  |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| ContentBytes : `Object` | <p>Source directory.</p><p><br>Default: <code>-</code><br>Example: <code>VGhpcyBpcyBhIHRlc3QgZmlsZS4=</code></p>             |
| Path : `String`         | <p>Full path of the target file to be written</p><p><br>Default: <code>-</code><br>Example: <code>c:\temp\foo.txt</code></p> |
| {% endtab %}            |                                                                                                                              |

{% tab title="Options" %}

| Name                                                    | Description                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| UseGivenUserCredentialsForRemoteConnections : `Boolean` | <p>If set, allows you to give the user credentials to use to delete files on remote hosts.</p><p>If not set, the agent service user credentials will be used.</p><p>Note: This feature is only possible with Windows agents.</p><p><br>Default: <code>False</code><br>Example: <code>true</code></p>                                                                                                                               |
| UserName : `String`                                     | <p>This needs to be of format domain\username</p><p><br>Default: <code>"domain\username"</code><br>Example: <code>domain\username</code></p>                                                                                                                                                                                                                                                                                       |
| 🗝Password : `String`                                   | <p>Password for the used credentials.</p><p><br>Default: <code>-</code><br>Example: <code>testpwd</code></p>                                                                                                                                                                                                                                                                                                                       |
| WriteBehaviour : `WriteBehaviour`                       | <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>: Throw an error and roll back all transfers.</li><li><code>Overwrite</code>: Overwrite the target file.</li><li><code>Throw</code>: Rename the transferred file by appending a number to the end.</li></ul><p><br>Default: <code>Throw</code><br>Example: <code>WriteBehaviour.Throw</code></p> |
| {% endtab %}                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| {% endtabs %}                                           |                                                                                                                                                                                                                                                                                                                                                                                                                                    |

## Task Result

| Name                       | Description                                                                |
| -------------------------- | -------------------------------------------------------------------------- |
| Path : `String`            | <p>Full path to the file.<br>Example: <code>c:\temp\foo.txt</code></p>     |
| SizeInMegaBytes : `Double` | <p>Size of the written file in mega bytes.<br>Example: <code>32</code></p> |

## Task Changelog

Changelog for Task Frends.Files.WriteBytes.

### \[1.1.0] - 2025-03-19

#### Changed

* Update packages: Microsoft.Extensions.FileSystemGlobbing 7.0.0 -> 9.0.3 System.ComponentModel.Annotations 4.7.0 -> 5.0.0 System.DirectoryServices 7.0.0 -> 8.0.0

### \[1.0.1] - 2023-08-10

#### Fixed

* Fixed memory leak from ExecuteWriteBytes by adding using statement when opening a new MewmoryStream.

### \[1.0.0] - 2023-04-17

#### 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/files/writebytes.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.
