# 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:** 21.0
- **Namespace:** `TXTextControl.Web`
- **Assembly:** `TXTextControl.Web.dll`, which the TX Text Control .NET Server setup installs, for .NET Framework; in no NuGet package
- **Path:** TX Text Control .NET Server > Reference > TXTextControl.Web > TextControl.LoadText Method
- **1285 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textcontrol/loadtext-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textcontrol/loadtext-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textcontrol/loadtext-method/llms-full.txt

---

### Description

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

### Syntax

#### LoadText(String, Web.StreamType)

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

```csharp
public void LoadText(string path, Web.StreamType streamType);
```

```vbnet
Public Sub LoadText(ByVal path As String, ByVal streamType As Web.StreamType)
```

| 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(System.IO.FileStream, Web.StreamType)

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

```csharp
public void LoadText(System.IO.FileStream fileStream, Web.StreamType streamType);
```

```vbnet
Public Sub LoadText(ByVal fileStream As System.IO.FileStream, ByVal streamType As Web.StreamType)
```

| 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\[\], Web.BinaryStreamType)

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

```csharp
public void LoadText(byte[] binaryData, Web.BinaryStreamType binaryStreamType);
```

```vbnet
Public Sub LoadText(ByVal binaryData As Byte(), ByVal binaryStreamType As Web.BinaryStreamType)
```

| 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, Web.StringStreamType)

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

```csharp
public void LoadText(string stringData, Web.StringStreamType stringStreamType);
```

```vbnet
Public Sub LoadText(ByVal stringData As String, ByVal stringStreamType As Web.StringStreamType)
```

| 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. |

### Examples

`LoadText` is not exposed by the current ASP.NET Core editor helper. The following example uses `LoadText` in the current server-side setup instead.

```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.LoadDataSetAsync Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textcontrol/loaddatasetasync-method/llms-full.txt)
- **Next:** [TextControl.LoadTextAsync Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textcontrol/loadtextasync-method/llms-full.txt)
