# WriteBytes

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>

{% tabs %}
{% tab title="Parameter: 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="Parameter: 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>:</li></ul><p>How the file write should work if a file with the new name already exists</p><ul><li><code>Overwrite</code>:</li></ul><p>How the file write should work if a file with the new name already exists</p><ul><li><code>Throw</code>:</li></ul><p>How the file write should work if a file with the new name already exists</p><p><br>Default: <code>2</code><br>Example: <code>WriteBehaviour.Throw</code></p> |
| {% endtab %}                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |

{% tab title="Result: 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> |
| {% endtab %}               |                                                                            |

{% tab title="Changelog" %}

## Changelog

### \[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
  {% endtab %}
  {% endtabs %}
