# DocumentController.SaveToMemory Method

> Saves the document that is currently loaded in the DocumentController.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 15.0
- **Namespace:** `TXTextControl.DocumentServer`
- **Package:** `TXTextControl.TextControl.WPF.SDK` (assembly `TXDocumentServer.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXDocumentServer.dll` from the setup
- **Path:** TX Text Control .NET for WPF > Reference > TXTextControl.DocumentServer > DocumentController.SaveToMemory Method
- **964 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/documentcontroller/savetomemory-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/documentcontroller/savetomemory-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/documentcontroller/savetomemory-method/llms-full.txt

---

### Description

Saves the document that is currently loaded in the DocumentController.

### Syntax

#### SaveToMemory(out byte\[\], BinaryStreamType, SaveSettings)

Saves the document that is currently loaded in the DocumentController to a byte array.

```csharp
public void SaveToMemory(out byte[] data, BinaryStreamType fileFormat, SaveSettings saveSettings);
```

```vbnet
Public Sub SaveToMemory(ByRef data As Byte(), fileFormat As BinaryStreamType, saveSettings As SaveSettings)
```

| Parameter | Description |
|---|---|
| data | Specifies a byte array or a string into which the data is saved. No memory needs to be allocated through the caller. |
| fileFormat | Specifies one of the [BinaryStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/binarystreamtype/enumeration/llms-full.txt) or the [StringStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/stringstreamtype/enumeration/llms-full.txt) values. |
| saveSettings | Specifies a [SaveSettings](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/savesettings/llms-full.txt) object with additional information and settings for the save operation. |

#### SaveToMemory(out string, StringStreamType, SaveSettings)

Saves the document that is currently loaded in the DocumentController to a string.

```csharp
public void SaveToMemory(out string data, StringStreamType fileFormat, SaveSettings saveSettings);
```

```vbnet
Public Sub SaveToMemory(ByRef data As String, fileFormat As StringStreamType, saveSettings As SaveSettings)
```

| Parameter | Description |
|---|---|
| data | Specifies a byte array or a string into which the data is saved. No memory needs to be allocated through the caller. |
| fileFormat | Specifies one of the [BinaryStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/binarystreamtype/enumeration/llms-full.txt) or the [StringStreamType](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/stringstreamtype/enumeration/llms-full.txt) values. |
| saveSettings | Specifies a [SaveSettings](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/savesettings/llms-full.txt) object with additional information and settings for the save operation. |

### Examples

The following example uses Save To Memory in a focused Document Controller workflow.

```csharp
byte[] data = new byte[] { 1 };
documentController.SaveToMemory(out data, BinaryStreamType.WordprocessingML, new SaveSettings());
```

```vbnet
Dim data As Byte() = New Byte() { 1 }
documentController.SaveToMemory(data, BinaryStreamType.WordprocessingML, New SaveSettings())
```

---

## Nearby

- **Previous:** [DocumentController.Save Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/documentcontroller/save-method/llms-full.txt)
- **Next:** [DocumentController.TextComponent Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/documentcontroller/textcomponent-property/llms-full.txt)
