# Write

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.Write>

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

| Name               | Description                                                                                                                  |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
| Content : `String` | <p>Source directory.</p><p><br>Default: <code>-</code><br>Example: <code>This is test content</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>Sets a value indicating whether remote connection is used.</p><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>Sets username. 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>Sets password for the used credentials.</p><p><br>Default: <code>-</code><br>Example: <code>testpwd</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| FileEncoding : `FileEncoding`                           | <p>Sets encoding for the written content. By selecting 'Other' you can use any encoding.</p><p>Possible values:</p><ul><li><code>UTF8</code>:</li></ul><p>Sets encoding for the written content. By selecting 'Other' you can use any encoding.</p><ul><li><code>Default</code>:</li></ul><p>Sets encoding for the written content. By selecting 'Other' you can use any encoding.</p><ul><li><code>ASCII</code>:</li></ul><p>Sets encoding for the written content. By selecting 'Other' you can use any encoding.</p><ul><li><code>Unicode</code>:</li></ul><p>Sets encoding for the written content. By selecting 'Other' you can use any encoding.</p><ul><li><code>Windows1252</code>:</li></ul><p>Sets encoding for the written content. By selecting 'Other' you can use any encoding.</p><ul><li><code>Other</code>:</li></ul><p>Sets encoding for the written content. By selecting 'Other' you can use any encoding.</p><p><br>Default: <code>0</code><br>Example: <code>FileEncoding.UTF8</code></p> |
| EnableBom : `Boolean`                                   | <p>Sets a value indicating whether enablation BOM for UTF-8.</p><p><br>Default: <code>False</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| EncodingInString : `String`                             | <p>Sets file encoding to be used. A partial list of possible encodings: <https://en.wikipedia.org/wiki/Windows_code_page#List>.</p><p><br>Default: <code>-</code><br>Example: <code>ISO-8859-2</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| WriteBehaviour : `WriteBehaviour`                       | <p>Sets write behaviour.</p><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>Sets write behaviour.</p><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>Sets write behaviour.</p><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>Sets write behaviour.</p><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> |
| SizeInKiloBytes : `Double` | <p>Size of the written file in kilo bytes.<br>Example: <code>32</code></p> |
| SizeInBytes : `Double`     | <p>Size of the written file in bytes.<br>Example: <code>32</code></p>      |
| {% endtab %}               |                                                                            |

{% tab title="Changelog" %}

## Changelog

### \[1.4.0] - 2025-11-04

#### Fixed

* Returning correct file size

### \[1.3.0] - 2025-06-05

#### Fixed

* Resolve issue with an unsupported library in .net 6.

#### Changed

* Downgrade package System.Text.Encoding.CodePages from 9.0.3 to 8.0.0
* Remove unused package Microsoft.Extensions.FileSystemGlobbing

### \[1.2.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 System.Text.Encoding.CodePages 8.0.0 -> 9.0.3 coverlet.collector 3.1.0 -> 6.0.4 Microsoft.NET.Test.Sdk 16.6.1 -> 17.13.0 MSTest.TestAdapter 2.2.7 -> 3.8.3 MSTest.TestFramework 2.2.8 -> 3.8.3 nunit 3.12.0 -> 4.3.2 NUnit3TestAdapter 3.17.0 -> 5.0.0

### \[1.1.0] - 2024-10-14

#### Fixed

* Renamed ANSI encoding to Default.

#### Added

* Added result properties SizeInKiloBytes and SizeInBytes.

### \[1.0.1] - 2024-02-27

#### Added

* Windows-1252 added to "Encoding" options.

### \[1.0.0] - 2023-02-15

#### Added

* Initial implementation
  {% endtab %}
  {% endtabs %}
