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

# Read

Reads a file from directory.

Task version: 1.3.0

Required Frends version: 5.7+

Required .NET version: 8.0

Compatible Agents: Crossplatform

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

## Task Parameters

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

| Name            | Description                                                                                                                |
| --------------- | -------------------------------------------------------------------------------------------------------------------------- |
| Path : `String` | <p>Full path of the target file to be read.</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>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| FileEncoding : `FileEncoding`                           | <p>Encoding for the written content. By selecting 'Other' you can use any encoding.</p><p>Possible values:</p><ul><li><code>UTF8</code>: Encoding for the written content. By selecting 'Other' you can use any encoding.</li><li><code>Default</code>: Encoding for the written content. By selecting 'Other' you can use any encoding.</li><li><code>ASCII</code>: Encoding for the written content. By selecting 'Other' you can use any encoding.</li><li><code>Unicode</code>: Encoding for the written content. By selecting 'Other' you can use any encoding.</li><li><code>Windows1252</code>: Encoding for the written content. By selecting 'Other' you can use any encoding.</li><li><code>Other</code>: Encoding for the written content. By selecting 'Other' you can use any encoding.</li></ul><p><br>Default: <code>UTF8</code><br>Example: <code>FileEncoding.UTF8</code></p> |
| EnableBom : `Boolean`                                   | <p>Enable BOM for UTF-8</p><p><br>Default: <code>False</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| EncodingInString : `String`                             | <p>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>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| 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. If <code>ThrowErrorOnFailure</code> is set to <code>true</code>, then the original exception will be wrapped in a new Exception with this error message.</p><p><br>Default: <code>-</code><br>Example: <code>Reading the file failed: file is missing</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| {% endtab %}                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| {% endtabs %}                                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |

## Task Result

| Name                               | Description                                                                                                                                  |
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| Success : `Boolean`                | <p>Indicates whether the operation completed successfully.<br>Example: <code>true</code></p>                                                 |
| Error : `Error`                    | <p>Error details. Null when Success is true.<br>Example: <code>null</code></p>                                                               |
| Error.Message : `String`           | <p>Summary of the error.<br>Example: <code>Could not find file 'c:\temp\foo.txt'.</code></p>                                                 |
| Error.AdditionalInfo : `Exception` | <p>The exception that caused the error.<br>Example: <code>System.IO.FileNotFoundException: Could not find file 'c:\temp\foo.txt'.</code></p> |
| Content : `String`                 | <p>File content.<br>Example: <code>This is a test file.</code></p>                                                                           |
| 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>                                                                        |
| CreationTime : `DateTime`          | <p>DateTime when file was created.<br>Example: <code>01/31/2023 10:54:17</code></p>                                                          |
| LastWriteTime : `DateTime`         | <p>DateTime for last write time of the file.<br>Example: <code>02/06/2023 09:59:13</code></p>                                                |

## Task Changelog

Changelog for Task Frends.Files.Read.

### \[1.3.0] - 2026-10-09

#### Changed

* Upgraded the Task to target .NET 8.
* The Task now throws an error on failure by default. Set `ThrowErrorOnFailure` to false in Options to receive a result with `Success` set to false and error details in `Error` instead.

#### Added

* Added `Success` and `Error` properties to the result.
* Added `ThrowErrorOnFailure` and `ErrorMessageOnFailure` options.

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

#### Changed

* Update packaged: 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 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

* Fixed documentation for Path parameter.

#### Added

* Added Windows1252 encoding to the FileEncoding enum.
* Added different sizes to the Task result.

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

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