Class PortfolioFileCollection
File entries at a portfolio root or folder scope.
Inherited Members
Namespace: DRIT.Pdf.EmbeddedFiles
Assembly: DRIT.Pdf.dll
Syntax
public sealed class PortfolioFileCollection : IEnumerable<PortfolioFile>, IEnumerable
Properties
Count
Gets the number of files in this collection.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
this[int]
Gets the file at the specified index.
Declaration
public PortfolioFile this[int index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The zero-based index. |
Property Value
| Type | Description |
|---|---|
| PortfolioFile |
Methods
Add(EmbeddedFile)
Adds an embedded file to this collection.
Declaration
public PortfolioFile Add(EmbeddedFile embeddedFile)
Parameters
| Type | Name | Description |
|---|---|---|
| EmbeddedFile | embeddedFile | The embedded file to add. |
Returns
| Type | Description |
|---|---|
| PortfolioFile | The created collection file entry. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
Add(string)
Adds a file from disk to this collection.
Declaration
public PortfolioFile Add(string filePath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filePath | The path to the file to add. |
Returns
| Type | Description |
|---|---|
| PortfolioFile | The created collection file entry. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
Add(string, Stream, string?)
Adds a file from a stream to this collection.
Declaration
public PortfolioFile Add(string name, Stream stream, string? mimeType = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The display name for the file. |
| Stream | stream | The stream containing file data. |
| string | mimeType | Optional MIME type for the file. |
Returns
| Type | Description |
|---|---|
| PortfolioFile | The created collection file entry. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
Add(string, string)
Adds a file from disk with a custom name to this collection.
Declaration
public PortfolioFile Add(string name, string filePath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The display name for the file. |
| string | filePath | The path to the file to add. |
Returns
| Type | Description |
|---|---|
| PortfolioFile | The created collection file entry. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
AddEmpty(string, string?)
Adds an empty file entry to this collection.
Declaration
public PortfolioFile AddEmpty(string name, string? mimeType = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The display name for the file. |
| string | mimeType | Optional MIME type for the file. |
Returns
| Type | Description |
|---|---|
| PortfolioFile | The created collection file entry. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
GetEnumerator()
Returns an enumerator for iterating over files.
Declaration
public IEnumerator<PortfolioFile> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<PortfolioFile> |
Remove(PortfolioFile)
Remove a file entry from this collection scope.
Declaration
public bool Remove(PortfolioFile file)
Parameters
| Type | Name | Description |
|---|---|---|
| PortfolioFile | file | The file entry to remove. |
Returns
| Type | Description |
|---|---|
| bool | True if the file was found and removed; false otherwise. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
RemoveAt(int)
Remove a file entry by zero-based index.
Declaration
public void RemoveAt(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The zero-based index of the file to remove. |
RemoveByName(string, StringComparison)
Remove the first file entry whose name matches name.
Declaration
public bool RemoveByName(string name, StringComparison comparison = StringComparison.OrdinalIgnoreCase)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The file name to match. |
| StringComparison | comparison | The string comparison type. Default is case-insensitive. |
Returns
| Type | Description |
|---|---|
| bool | True if a matching file was found and removed; false otherwise. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when |