# WriteTextFile

> Writes the specified text into a file. If the file already exists, the pre-existing text is overwritten. If the file does not exist, it is created.

Writes the specified text into a file. If the file already exists, the pre-existing text is overwritten. If the file does not exist, it is created.

## Definition

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

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

## Overloads

|  |  |
| --- | --- |
| `WriteTextFile(String, ILocalResource)` | Writes the specified text into a file. If the file already exists, the pre-existing text is overwritten. |
| `WriteTextFile(String, ILocalResource, String)` | Writes the specified text into a file. If the file already exists, the pre-existing text is overwritten. You can also choose the encoding name for decoding the file content. |

## `WriteTextFile(String, ILocalResource)`

Writes the specified text into a file. If the file already exists, the pre-existing text is overwritten.

```
void WriteTextFile(
    string text,
    ILocalResource file
)
```

`text` [String](https://learn.microsoft.com/dotnet/api/system.string) : The text to be written into the file.

`file` `ILocalResource` : The file to write to. 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.

## `WriteTextFile(String, ILocalResource, String)`

Writes the specified text into a file. If the file already exists, the pre-existing text is overwritten. You can also choose the encoding name for decoding the file content.

```
void WriteTextFile(
    string text,
    ILocalResource file,
    string encoding
)
```

`text` [String](https://learn.microsoft.com/dotnet/api/system.string) : The text to be written into the file.

`file` `ILocalResource` : The file to write to. 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) : The encoding type to be used. You can find the complete list of codes for each character encoding [here](https://docs.uipath.com/activities/other/latest/user-guide/supported-character-encoding). To specify the encoding type to be used, use the value from the **Name** field. 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.
