# Selection.Save Method

> Saves the selected text of a document with the specified format.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 22.0
- **Namespace:** `TXTextControl.Web`
- **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 > Selection.Save Method
- **1233 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/selection/save-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/selection/save-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/selection/save-method/llms-full.txt

---

### Description

Saves the selected text of a document with the specified format.

### Syntax

#### Save(string, StreamType)

Saves the selected text of a document in the specified file with the specified format.

```csharp
public void Save(string path, StreamType streamType);
```

```vbnet
Public Sub Save(path As String, streamType As StreamType)
```

| Parameter | Description |
|---|---|
| path | Saves the selected text of a document in the specified file with the specified format. |
| streamType | Specifies one of the [StringStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/stringstreamtype/enumeration/llms-full.txt) values. |

#### Save(FileStream, StreamType)

Saves the selected text of a document in the specified file stream with the specified format.

```csharp
public void Save(FileStream fileStream, StreamType streamType);
```

```vbnet
Public Sub Save(fileStream As FileStream, streamType As StreamType)
```

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

#### Save(out byte\[\], BinaryStreamType)

Saves the selected text of a document in the specified byte array with the specified format.

```csharp
public void Save(out byte[] data, BinaryStreamType streamType);
```

```vbnet
Public Sub Save(ByRef data As Byte(), streamType As BinaryStreamType)
```

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

#### Save(out string, StringStreamType)

Saves the selected text of a document as a string with the specified format.

```csharp
public void Save(out string stringData, StringStreamType streamType);
```

```vbnet
Public Sub Save(ByRef stringData As String, streamType As StringStreamType)
```

| Parameter | Description |
|---|---|
| stringData | Specifies a string into which the selection is saved. No memory needs to be allocated through the caller. |
| streamType | Specifies one of the [StringStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/stringstreamtype/enumeration/llms-full.txt) values. |

### Examples

The following example uses `Selection.Save` in a document-processing workflow.

```csharp
selection.Save(@"App_Data\document.docx", TXTextControl.Web.StreamType.PlainAnsiText);
Console.WriteLine("Save completed for the Selection workflow.");
```

```vbnet
selection.Save("App_Data\document.docx", TXTextControl.Web.StreamType.PlainAnsiText)
Console.WriteLine("Save completed for the Selection workflow.")
```

---

## Nearby

- **Previous:** [Selection.Load Method](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/selection/load-method/llms-full.txt)
- **Next:** [Selection.Start Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-web/selection/start-property/llms-full.txt)
