# ReadTextFile

> Reads all characters from a specified file and stores it in a String variable.

Reads all characters from a specified file and stores it in a String variable.

## Definition

**Namespace:** UiPath.Activities.System.API

**Assembly:** UiPath.System.Activities.Api (in UiPath.System.Activities.Api.dll)

## Overloads

|  |  |
| --- | --- |
| `ReadTextFile(IResource)` | Reads all characters from a specified file and stores it in a String variable. |
| `ReadTextFile(IResource, String)` | Reads all characters from a specified file, while detecting the encoding, and stores it in a String variable. |

## `ReadTextFile(IResource)`

Reads all characters from a specified file and stores it in a String variable.

```
string ReadTextFile(
    IResource file,
)
```

`file` `IResource` : The file to be read. You can choose to configure the file either as an **IResource** or **Local File**. If you choose to use a local file, you need to add just the file name and extension and make sure the file exists in the root of the project folder.

## `ReadTextFile(IResource, String)`

Reads all characters from a specified file, while detecting the encoding, and stores it in a String variable.

```
string ReadTextFile(
    IResource file,
    string encoding
)
```

`file` `IResource` : The file to be read. You can choose to configure the file either as an **IResource** or **Local File**. If you choose to use a local file, you need to add just the file name and extension and make sure the file exists in the root of the project folder.

`encoding` [String](https://learn.microsoft.com/dotnet/api/system.string) : If no encoding type is specified, the activity will search for the file's Byte Order Marks to detect the encoding. If no Byte Order Marks are detected, the system ANSI code page is selected by default.

## Return value

[String](https://learn.microsoft.com/dotnet/api/system.string)

The extracted text from the file stored into a string variable.
