# TextControl.LoadText Method

> Loads text in a certain format. The complete contents of a TextControl are replaced.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 23.0
- **Namespace:** `TXTextControl.Web.MVC`
- **Package:** `TXTextControl.Web` (assembly `TXTextControl.Web.DocumentEditor.dll`, from nuget.org, the private NuGet feed or Text Control Offline Packages)
- **Path:** TX Text Control .NET Server > Reference > TXTextControl.Web.MVC > TextControl.LoadText Method
- **1227 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web-mvc/textcontrol/loadtext-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web-mvc/textcontrol/loadtext-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web-mvc/textcontrol/loadtext-method/llms-full.txt

---

### Description

Loads text in a certain format. The complete contents of a TextControl are replaced.

### Syntax

#### LoadText(string, StreamType)

Loads text formatted with the specified format. The new text is read from the specified file.

```csharp
public TextControl LoadText(string path, StreamType streamType);
```

```vbnet
Public Function LoadText(path As String, streamType As StreamType) As TextControl
```

| Parameter | Description |
|---|---|
| path | Specifies a file from which the data is loaded. |
| streamType | Specifies one of the [StreamType](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/streamtype/enumeration/llms-full.txt) values. |

#### LoadText(FileStream, StreamType)

Loads text formatted with the specified format. The new text is read from the specified file stream.

```csharp
public TextControl LoadText(FileStream fileStream, StreamType streamType);
```

```vbnet
Public Function LoadText(fileStream As FileStream, streamType As StreamType) As TextControl
```

| Parameter | Description |
|---|---|
| fileStream | Specifies a file from which the data is loaded. The data is loaded from the stream's current position. |
| streamType | Specifies one of the [StreamType](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/streamtype/enumeration/llms-full.txt) values. |

#### LoadText(byte\[\], BinaryStreamType)

Loads text formatted with the specified format. The new text is read from the specified byte array.

```csharp
public TextControl LoadText(byte[] binaryData, BinaryStreamType binaryStreamType);
```

```vbnet
Public Function LoadText(binaryData As Byte(), binaryStreamType As BinaryStreamType) As TextControl
```

| Parameter | Description |
|---|---|
| binaryData | Specifies a byte array from which the data is loaded. |
| binaryStreamType | Specifies one of the [BinaryStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/binarystreamtype/enumeration/llms-full.txt) values. |

#### LoadText(string, StringStreamType)

Loads text formatted with the specified format. The new text is read from the specified string.

```csharp
public TextControl LoadText(string stringData, StringStreamType stringStreamType);
```

```vbnet
Public Function LoadText(stringData As String, stringStreamType As StringStreamType) As TextControl
```

| Parameter | Description |
|---|---|
| stringData | Specifies a string from which the data is loaded. |
| stringStreamType | Specifies one of the [StringStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/stringstreamtype/enumeration/llms-full.txt) values. |

### Return Value

A reference to the `Web.MVC.TextControl` instance to allow method chaining.

### Examples

The following example uses `TextControl.LoadText` in a document-processing workflow.

```csharp
var result = textControl.LoadText(@"App_Data\document.docx", TXTextControl.Web.StreamType.PlainAnsiText);
Console.WriteLine(result);
```

```vbnet
Dim result = textControl.LoadText("App_Data\document.docx", TXTextControl.Web.StreamType.PlainAnsiText)
Console.WriteLine(result)
```

---

## Nearby

- **Previous:** [TextControl.LoadDataSet Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web-mvc/textcontrol/loaddataset-method/llms-full.txt)
- **Next:** [TextControl.LoadXMLDatabase Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web-mvc/textcontrol/loadxmldatabase-method/llms-full.txt)
