# EmbeddedFile Constructor

> Initializes a new instance of the EmbeddedFile class.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Constructor
- **Introduced:** 29.0
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WPF.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Path:** TX Text Control .NET for WPF > Reference > TXTextControl > EmbeddedFile Constructor
- **1529 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/embeddedfile/constructor/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/embeddedfile/constructor/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/embeddedfile/constructor/llms-full.txt

---

### Description

Initializes a new instance of the EmbeddedFile class.

### Syntax

#### EmbeddedFile(string, SafeFileHandle, string)

Initializes a new instance of an embedded file with the specified name. The file's data is given through the specified file handle. When the document is saved, the data is read from the file and embedded in the document.

```csharp
public EmbeddedFile(string fileName, SafeFileHandle handle, string metaData);
```

```vbnet
Public Sub New(fileName As String, handle As SafeFileHandle, metaData As String)
```

| Parameter | Description |
|---|---|
| fileName | Specifies the file's name. The name can include a relative or absolute path. |
| handle | Identifies a file from which the data to embed is read. |
| metaData | Specifies additional metadata with properties of the document which is embedded. The data is added to the metadata of the containing document. The string must consist of one or more rdf:Description elements as specified by the XMP Specification (XMP: Extensible Metadata Platform, Adobe Systems Incorporated) or the RDF Model and Syntax Specification (http://www.w3.org/TR/rdf-syntax-grammar/). rdf is the XML namespace prefix for the "http://www.w3.org/1999/02/22-rdf-syntax-ns#" namespace. It can be null or an empty string, if there is no additional meta data to embed. |

#### EmbeddedFile(string, string, string)

Initializes a new instance of an embedded file with the specified name and string data.

```csharp
public EmbeddedFile(string fileName, string data, string metaData);
```

```vbnet
Public Sub New(fileName As String, data As String, metaData As String)
```

| Parameter | Description |
|---|---|
| fileName | Specifies the file's name. The name can include a relative or absolute path. |
| data | Specifies the file's data. The data can be a string or binary data. |
| metaData | Specifies additional metadata with properties of the document which is embedded. The data is added to the metadata of the containing document. The string must consist of one or more rdf:Description elements as specified by the XMP Specification (XMP: Extensible Metadata Platform, Adobe Systems Incorporated) or the RDF Model and Syntax Specification (http://www.w3.org/TR/rdf-syntax-grammar/). rdf is the XML namespace prefix for the "http://www.w3.org/1999/02/22-rdf-syntax-ns#" namespace. It can be null or an empty string, if there is no additional meta data to embed. |

#### EmbeddedFile(string, byte\[\], string)

Initializes a new instance of an embedded file with the specified name and binary data.

```csharp
public EmbeddedFile(string fileName, byte[] data, string metaData);
```

```vbnet
Public Sub New(fileName As String, data As Byte(), metaData As String)
```

| Parameter | Description |
|---|---|
| fileName | Specifies the file's name. The name can include a relative or absolute path. |
| data | Specifies the file's data. The data can be a string or binary data. |
| metaData | Specifies additional metadata with properties of the document which is embedded. The data is added to the metadata of the containing document. The string must consist of one or more rdf:Description elements as specified by the XMP Specification (XMP: Extensible Metadata Platform, Adobe Systems Incorporated) or the RDF Model and Syntax Specification (http://www.w3.org/TR/rdf-syntax-grammar/). rdf is the XML namespace prefix for the "http://www.w3.org/1999/02/22-rdf-syntax-ns#" namespace. It can be null or an empty string, if there is no additional meta data to embed. |

### Examples

The following example embeds a PDF attachment and preserves its media type during WordprocessingML export.

```csharp
EmbeddedFile embeddedFile = new("terms.pdf", @"Attachments\terms.pdf", "application/pdf");
SaveSettings saveSettings = new() { EmbeddedFiles = new[] { embeddedFile } };
textControl.Save("contract-with-attachment.docx", StreamType.WordprocessingML, saveSettings);
```

```vbnet
Dim embeddedFile As New EmbeddedFile("terms.pdf", "Attachments\terms.pdf", "application/pdf")
Dim saveSettings As New SaveSettings() With { .EmbeddedFiles = New EmbeddedFile() { embeddedFile } }
textControl.Save("contract-with-attachment.docx", StreamType.WordprocessingML, saveSettings)
```

---

## Nearby

- **Previous:** [EmbeddedFile Class](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/embeddedfile/llms-full.txt)
- **Next:** [EmbeddedFile.CreationDate Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/embeddedfile/creationdate-property/llms-full.txt)
