# ReadFile

Required Frends version: 5.7+

Required .NET version: 8.0

Compatible Agents: Unknown

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

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

| Name                | Description                                                                                                         |
| ------------------- | ------------------------------------------------------------------------------------------------------------------- |
| Path : `PathString` | <p>Full path to the file to be read.</p><p><br>Default: <code>-</code><br>Example: <code>folder\file.txt</code></p> |
| {% endtab %}        |                                                                                                                     |

{% tab title="Parameter: 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>:</li></ul><p>Defines the operating system of the SMB server.</p><p>Options used to determine correct path separator to use.</p><ul><li><code>Linux</code>:</li></ul><p>Defines the operating system of the SMB server.</p><p>Options used to determine correct path separator to use.</p><p><br>Default: <code>2</code><br>Example: <code>Linux</code></p> |
| {% endtab %}           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |

{% tab title="Parameter: Options" %}

| Name                             | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| UseEncoding : `Boolean`          | <p>Whether to attempt decoding the file content to text.</p><p>If false, TextContent will be null for all files.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| FileEncoding : `FileEncoding`    | <p>Encoding for the file content.</p><p>By selecting 'Other' you can use any encoding.</p><p>Possible values:</p><ul><li><code>Utf8</code>:</li></ul><p>Encoding for the file content.</p><p>By selecting 'Other' you can use any encoding.</p><ul><li><code>Default</code>:</li></ul><p>Encoding for the file content.</p><p>By selecting 'Other' you can use any encoding.</p><ul><li><code>Ascii</code>:</li></ul><p>Encoding for the file content.</p><p>By selecting 'Other' you can use any encoding.</p><ul><li><code>Unicode</code>:</li></ul><p>Encoding for the file content.</p><p>By selecting 'Other' you can use any encoding.</p><ul><li><code>Windows1252</code>:</li></ul><p>Encoding for the file content.</p><p>By selecting 'Other' you can use any encoding.</p><ul><li><code>Other</code>:</li></ul><p>Encoding for the file content.</p><p>By selecting 'Other' you can use any encoding.</p><p><br>Default: <code>1</code><br>Example: <code>FileEncoding.Default</code></p> |
| EnableBom : `Boolean`            | <p>Enable BOM (Byte Order Mark) for UTF-8 encoding.</p><p><br>Default: <code>False</code><br>Example: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| EncodingInString : `String`      | <p>File encoding to be used when FileEncoding is set to 'Other'.</p><p>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>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| 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 %}                     |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

{% tab title="Result: Result" %}

| Name                                 | Description                                                                                                                                                                                     |
| ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Success : `Boolean`                  | <p>Indicates if the task completed successfully.<br>Example: <code>true</code></p>                                                                                                              |
| Content : `Byte[]`                   | <p>File content as a byte array. This property contains the raw bytes of the file, suitable for both text and binary files.<br>Example: <code>byte\[] { 72, 101, 108, 108, 111 }</code></p>     |
| TextContent : `String`               | <p>File content as a decoded text string (if applicable). This is populated only if the file can be successfully decoded using the specified encoding.<br>Example: <code>Hello World</code></p> |
| Path : `PathString`                  | <p>The full path of the file that was read.<br>Example: <code>c:\temp\foo.txt</code></p>                                                                                                        |
| SizeInMegaBytes : `Double`           | <p>Size of the read file in megabytes.<br>Example: <code>32</code></p>                                                                                                                          |
| CreationTime : `Nullable<DateTime>`  | <p>DateTime when file was created.<br>Example: <code>01/31/2023 10:54:17</code></p>                                                                                                             |
| LastWriteTime : `Nullable<DateTime>` | <p>DateTime for last write time of the file.<br>Example: <code>02/06/2023 09:59:13</code></p>                                                                                                   |
| Error : `Error`                      | <p>Error that occurred during task execution.<br>Example: <code>object { string Message, Exception AdditionalInfo }</code></p>                                                                  |
| {% endtab %}                         |                                                                                                                                                                                                 |

{% tab title="Changelog" %}

## Changelog

### \[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.1.0] - 2025-12-29

#### Changed

* Change the default value of Options.UseEncoding to true

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

#### Added

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