# TextControl.SaveText Method

> Saves the complete contents of a document with the specified format.

- **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.SaveText Method
- **1329 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textcontrol/savetext-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textcontrol/savetext-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textcontrol/savetext-method/llms-full.txt

---

### Description

Saves the complete contents of a document with the specified format.

### Syntax

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

Saves the complete contents of a document in the specified file with the specified format.

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

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

| Parameter | Description |
|---|---|
| path | Specifies a file into which the data is saved. If the file does not exist it is created. If the file exists its contents are overwritten. |
| streamType | Specifies one of the [StreamType](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/streamtype/enumeration/llms-full.txt) values. |

#### SaveText(System.IO.FileStream, Web.StreamType)

Saves the complete contents of a document in the specified file stream with the specified format.

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

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

| Parameter | Description |
|---|---|
| fileStream | Specifies a file into which the data is saved. The data is saved at 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. |

#### SaveText(Byte\[\], Web.BinaryStreamType)

Saves the complete contents of a document in the specified byte array with the specified format.

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

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

| Parameter | Description |
|---|---|
| binaryData | Specifies a byte array into which the data is saved. No memory needs to be allocated through the caller. |
| binaryStreamType | Specifies one of the [BinaryStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/binarystreamtype/enumeration/llms-full.txt) values. |

#### SaveText(String, Web.StringStreamType)

Saves the complete contents of a document as a string with the specified format.

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

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

| Parameter | Description |
|---|---|
| stringData | Specifies a string into which the data is saved. No memory needs to be allocated through the caller. |
| 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

`SaveText` 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.SaveDocumentQuestionDialogEnabled Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textcontrol/savedocumentquestiondialogenabled-property/llms-full.txt)
- **Next:** [TextControl.Selection Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/textcontrol/selection-property/llms-full.txt)
