Show / Hide Table of Contents

Method AddAttachmentAsync

AddAttachmentAsync(string, string, string)

Adds a new attachment to this AttachmentsFormElement from the specified file using the supplied final attachment name.

Declaration
public Task<FormAttachment> AddAttachmentAsync(string name, string contentType, string filePath)
Parameters
Type Name Description
string name

The attachment name.

string contentType

The type of content.

string filePath

Path to a file that will be used for the attachment's content.

Returns
Type Description
Task<FormAttachment>

A Task that returns a FormAttachment.

Remarks

The attachment name is provided by the name parameter. When UseOriginalFilename is true the provided value will be used, but when UseOriginalFilename is false the name parameter is ignored and one is generated automatically instead.

If the attachment is an image and it exceeds the maximum size specified by MaxImageSize, it will be resized to meet that requirement before being added.

FileNotFoundException will be set if the file does not exist.

FeatureFormExceedsMaximumAttachmentCountException will be set if adding this attachment would exceed the maximum number of attachments allowed.

FeatureFormExceedsMaximumAttachmentDurationException will be set if the attachment exceeds the maximum duration specified by MaxDuration or MaxDuration.

FeatureFormExceedsMaximumAttachmentSizeException will be set if the attachment exceeds the maximum size specified by MaxFileSize.

FeatureFormIncorrectAttachmentTypeException will be set if the type of the FormAttachment does not match an allowed attachments form input type.

Applies to

Platforms and versions
TargetVersions
.NET300.0 - 300.1
.NET Windows300.0 - 300.1
.NET Android300.0 - 300.1
.NET iOS300.0 - 300.1

AddAttachmentAsync(string, byte[], CancellationToken)

Asynchronously adds a new attachment to this AttachmentsFormElement.

Declaration
public Task<FormAttachment> AddAttachmentAsync(string contentType, byte[] data, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string contentType

The type of content.

byte[] data

The attachment data.

CancellationToken cancellationToken

A cancellation token that can be used to cancel the operation.

Returns
Type Description
Task<FormAttachment>

A Task that returns a FormAttachment.

Remarks

The attachment name is generated automatically. When you wish to provide a custom name and UseOriginalFilename is true, use the overload of this method that takes a name parameter.

If the attachment is an image and it exceeds the maximum size specified by MaxImageSize, it will be resized to meet that requirement before being added.

FeatureFormExceedsMaximumAttachmentCountException will be set if adding this attachment would exceed the maximum number of attachments allowed.

FeatureFormExceedsMaximumAttachmentDurationException will be set if the attachment exceeds the maximum duration specified by MaxDuration or MaxDuration.

FeatureFormExceedsMaximumAttachmentSizeException will be set if the attachment exceeds the maximum size specified by MaxFileSize.

FeatureFormIncorrectAttachmentTypeException will be set if the type of the FormAttachment does not match an allowed input type.

Applies to

Platforms and versions
TargetVersions
.NET300.1
.NET Windows300.1
.NET Android300.1
.NET iOS300.1

AddAttachmentAsync(string, ReadOnlySpan<byte>, CancellationToken)

Asynchronously adds a new attachment to this AttachmentsFormElement.

Declaration
public Task<FormAttachment> AddAttachmentAsync(string contentType, ReadOnlySpan<byte> data, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string contentType

The type of content.

ReadOnlySpan<byte> data

The attachment data.

CancellationToken cancellationToken

A cancellation token that can be used to cancel the operation.

Returns
Type Description
Task<FormAttachment>

A Task that returns a FormAttachment.

Remarks

The attachment name is generated automatically. When you wish to provide a custom name and UseOriginalFilename is true, use the overload of this method that takes a name parameter.

If the attachment is an image and it exceeds the maximum size specified by MaxImageSize, it will be resized to meet that requirement before being added.

FeatureFormExceedsMaximumAttachmentCountException will be set if adding this attachment would exceed the maximum number of attachments allowed.

FeatureFormExceedsMaximumAttachmentDurationException will be set if the attachment exceeds the maximum duration specified by MaxDuration or MaxDuration.

FeatureFormExceedsMaximumAttachmentSizeException will be set if the attachment exceeds the maximum size specified by MaxFileSize.

FeatureFormIncorrectAttachmentTypeException will be set if the type of the FormAttachment does not match an allowed input type.

Applies to

Platforms and versions
TargetVersions
.NET300.1
.NET Windows300.1
.NET Android300.1
.NET iOS300.1

AddAttachmentAsync(string, string, CancellationToken)

Asynchronously adds a new attachment to this AttachmentsFormElement from the specified file.

Declaration
public Task<FormAttachment> AddAttachmentAsync(string contentType, string filePath, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string contentType

The type of content.

string filePath

Path to a file that will be used for the attachment's content.

CancellationToken cancellationToken

A cancellation token that can be used to cancel the operation.

Returns
Type Description
Task<FormAttachment>

A Task that returns a FormAttachment.

Remarks

The attachment name is generated automatically. When you wish to provide a custom name and UseOriginalFilename is true, use the overload of this method that takes a name parameter.

If the attachment is an image and it exceeds the maximum size specified by MaxImageSize, it will be resized to meet that requirement before being added.

FileNotFoundException will be set if the file does not exist.

FeatureFormExceedsMaximumAttachmentCountException will be set if adding this attachment would exceed the maximum number of attachments allowed.

FeatureFormExceedsMaximumAttachmentDurationException will be set if the attachment exceeds the maximum duration specified by MaxDuration or MaxDuration.

FeatureFormExceedsMaximumAttachmentSizeException will be set if the attachment exceeds the maximum size specified by MaxFileSize.

FeatureFormIncorrectAttachmentTypeException will be set if the type of the FormAttachment does not match an allowed input type.

Applies to

Platforms and versions
TargetVersions
.NET300.1
.NET Windows300.1
.NET Android300.1
.NET iOS300.1

AddAttachmentAsync(string, string, byte[], CancellationToken)

Asynchronously adds a new attachment to this AttachmentsFormElement using the supplied final attachment name.

Declaration
public Task<FormAttachment> AddAttachmentAsync(string name, string contentType, byte[] data, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string name

The attachment name.

string contentType

The type of content.

byte[] data

The attachment data.

CancellationToken cancellationToken

A cancellation token that can be used to cancel the operation.

Returns
Type Description
Task<FormAttachment>

A Task that returns a FormAttachment.

Remarks

The attachment name is provided by the name parameter. When UseOriginalFilename is true the provided value will be used, but when UseOriginalFilename is false the name parameter is ignored and one is generated automatically instead.

If the attachment is an image and it exceeds the maximum size specified by MaxImageSize, it will be resized to meet that requirement before being added.

FeatureFormExceedsMaximumAttachmentCountException will be set if adding this attachment would exceed the maximum number of attachments allowed.

FeatureFormExceedsMaximumAttachmentDurationException will be set if the attachment exceeds the maximum duration specified by MaxDuration or MaxDuration.

FeatureFormExceedsMaximumAttachmentSizeException will be set if the attachment exceeds the maximum size specified by MaxFileSize.

FeatureFormIncorrectAttachmentTypeException will be set if the type of the FormAttachment does not match an allowed input type.

Applies to

Platforms and versions
TargetVersions
.NET300.1
.NET Windows300.1
.NET Android300.1
.NET iOS300.1

AddAttachmentAsync(string, string, ReadOnlySpan<byte>, CancellationToken)

Asynchronously adds a new attachment to this AttachmentsFormElement using the supplied final attachment name.

Declaration
public Task<FormAttachment> AddAttachmentAsync(string name, string contentType, ReadOnlySpan<byte> data, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string name

The attachment name.

string contentType

The type of content.

ReadOnlySpan<byte> data

The attachment data.

CancellationToken cancellationToken

A cancellation token that can be used to cancel the operation.

Returns
Type Description
Task<FormAttachment>

A Task that returns a FormAttachment.

Remarks

The attachment name is provided by the name parameter. When UseOriginalFilename is true the provided value will be used, but when UseOriginalFilename is false the name parameter is ignored and one is generated automatically instead.

If the attachment is an image and it exceeds the maximum size specified by MaxImageSize, it will be resized to meet that requirement before being added.

FeatureFormExceedsMaximumAttachmentCountException will be set if adding this attachment would exceed the maximum number of attachments allowed.

FeatureFormExceedsMaximumAttachmentDurationException will be set if the attachment exceeds the maximum duration specified by MaxDuration or MaxDuration.

FeatureFormExceedsMaximumAttachmentSizeException will be set if the attachment exceeds the maximum size specified by MaxFileSize.

FeatureFormIncorrectAttachmentTypeException will be set if the type of the FormAttachment does not match an allowed input type.

Applies to

Platforms and versions
TargetVersions
.NET300.1
.NET Windows300.1
.NET Android300.1
.NET iOS300.1
In this article
Provide feedback
Back to top Copyright © 2025 Esri.