# FileAttachment Class

> A file attachment.

- Product: Adobe PDF Library 21
- Language: .NET Framework
- Version: APDFL21.0.0PlusP1e
- HTML page: https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/FileAttachment
- Version index: https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/llms.txt

```csharp
class FileAttachment : SystemIDisposable
```

**Namespace:** `Datalogics::PDFL`

**Inherits from:** `SystemIDisposable`

## Description

A file attachment. Any file can be attached to the PDF document.

The class allows to create attachment and manipulate by its content.

**Referenced by:** [`Document`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Document.md)

**Uses types:** [`AFRelationship`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/enum/AFRelationship.md), [`CollectionSchemaField`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/CollectionSchemaField.md), [`Document`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Document.md)

## Constructors

### FileAttachment

```csharp
Datalogics.PDFL.FileAttachment.FileAttachment(Document doc, string fileName)
```

*constructor*

**Parameters**

- `doc` ([`Document`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Document.md)): The PDF document (reference).
- `fileName` (`string`): The path to file which will be attached to the document.

Allows to add attachment into the PDF document.

### FileAttachment

```csharp
Datalogics.PDFL.FileAttachment.FileAttachment(Document doc, string fileName, string keyName)
```

*constructor*

**Parameters**

- `doc` ([`Document`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Document.md)): The PDF document (reference).
- `fileName` (`string`): The path to file which will be attached to the document.
- `keyName` (`string`): The name of the key.

Allows to add attachment into the PDF document using the specified key name.

## Properties

### AFRelationship

```csharp
AFRelationship Datalogics.PDFL.FileAttachment.AFRelationship { get; set; }
```

Gets the attachment's Associated File relationship.

### FileName

```csharp
string Datalogics.PDFL.FileAttachment.FileName { get; }
```

Gets the attachment's file name.

### FileSize

```csharp
uint Datalogics.PDFL.FileAttachment.FileSize { get; }
```

Gets the attachment's file size.

## Methods

### Dispose

```csharp
void Datalogics.PDFL.FileAttachment.Dispose()
```

**Returns:** `void`

### GetCollectionItemNumber

```csharp
float Datalogics.PDFL.FileAttachment.GetCollectionItemNumber(CollectionSchemaField collectionField)
```

**Parameters**

- `collectionField` ([`CollectionSchemaField`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/CollectionSchemaField.md)): the field for which item value should be retrieved.

**Returns:** `float`

collection items value

GetCollectionItemNumber allows to obtain collection item according to the specified schema field.

### GetCollectionItemString

```csharp
string Datalogics.PDFL.FileAttachment.GetCollectionItemString(CollectionSchemaField collectionField)
```

**Parameters**

- `collectionField` ([`CollectionSchemaField`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/CollectionSchemaField.md)): the field for which item value should be retrieved.

**Returns:** `string`

collection items value

GetCollectionItemString allows to obtain collection item value according to the specified schema field.

### SaveToFile

```csharp
void Datalogics.PDFL.FileAttachment.SaveToFile(string fileName)
```

**Parameters**

- `fileName` (`string`): The path where attachment will be saved.

**Returns:** `void`

Allows to save attachment to the specified file.

### SaveToStream

```csharp
void Datalogics.PDFL.FileAttachment.SaveToStream(System.IO.Stream stream)
```

**Parameters**

- `stream` (`System.IO.Stream`): The Stream to which the FileAttachment is saved.

**Returns:** `void`

Saves a FileAttachment to a Stream.

### SetCollectionItemNumber

```csharp
void Datalogics.PDFL.FileAttachment.SetCollectionItemNumber(CollectionSchemaField collectionField, float value)
```

**Parameters**

- `collectionField` ([`CollectionSchemaField`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/CollectionSchemaField.md)): schema field which contains information about data type. The parameter's subtype should be a Number.
- `value` (`float`): the item's value.

**Returns:** `void`

SetCollectionItemNumber allows to add key to the collection item dictionary.

**Exceptions**

- `bad`: parameter exception if CollectionSchema doesn't contain specified field.

### SetCollectionItemString

```csharp
void Datalogics.PDFL.FileAttachment.SetCollectionItemString(CollectionSchemaField collectionField, string value)
```

**Parameters**

- `collectionField` ([`CollectionSchemaField`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/CollectionSchemaField.md)): schema field which contains information about data type. The parameter's subtype should be a Text.
- `value` (`string`): the item's value.

**Returns:** `void`

SetCollectionItemString allows to add key to the collection item dictionary.

**Exceptions**

- `bad`: parameter exception if CollectionSchema doesn't contain specified field.

### UpdateFromFile

```csharp
void Datalogics.PDFL.FileAttachment.UpdateFromFile(string fileName)
```

**Parameters**

- `fileName` (`string`): The path to the file from which attachment will be updated.

**Returns:** `void`

Allows to update attachment from another file.
