Skip To Content

FeatureAttachment.AddAsync (.NET)

The FeatureAttachment.AddAsync method attaches a file to a feature of a web feature layer that supports attachments when the user's role supports editing or higher. New features must be synchronized before adding attachments.

Declaration

public async Task<bool> Esri.ArcGISForAutoCAD.FeatureAttachment.AddAsync(Document doc, string flName, ObjectId objId, string filePath)

Parameters

TypeNameDescriptionRequired

Document

doc

The AutoCAD document to act on.

required

string

flName

An existing web feature layer name in the drawing that supports attachments.

required

ObjectId

objId

The AutoCAD ObjectId of a feature that an attachment will be added to.

required

string

filePath

The destination file path for the attached file.

required

Returns

TypeDescription

bool

true if the attachment was added successfully

Remarks on error conditions

This method may throw an exception or return false or null if a parameter is invalid or the web feature layer does not support attachments.

Example

Print the success of adding an attachment to a selected entity from the Damage_to_Residential_Buildings web feature layer.

// Initialize
var doc = Application.DocumentManager.MdiActiveDocument;
var flName = "Damage_to_Residential_Buildings";
var objId = Esri.ArcGISForAutoCAD.FeatureLayer.SelectEntity(doc, flName);
var filePath = @"C:\CADwork\Attachments\Olympus_Subdivision-2.0.xml";

// Add the attachment
var success = await Esri.ArcGISForAutoCAD.FeatureAttachment.AddAsync(doc, flName, objId, filePath);

// Print the success
doc.Editor.WriteMessage(success.ToString());

/* Example output
True
*/

See also

FeatureLayer.SelectEntity—A .NET method that prompts for the selection of one entity and returns its AutoCAD ObjectId.

WebFeatureLayer.SupportsAttachmentsAsync—A .NET method that specifies whether a web feature layer supports attachments by returning true if it does or false if it does not.

esri_webfeaturelayer_addAttachent—An AutoLISP function that attaches a file to a feature of a web feature layer that supports attachments.