ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Editing Namespace / EditOperation Class / AddAttachment Method / AddAttachment(RowToken,String) Method
The RowToken representing the future row to add the attachment to.
The filesystem path to the file to attach to the row.
Example

In This Topic
    AddAttachment(RowToken,String) Method
    In This Topic
    Add an attachment to a row with attachment support.
    Syntax
    Public Overloads Sub AddAttachment( _
       ByVal token As RowToken, _
       ByVal filePath As String _
    ) 
    public void AddAttachment( 
       RowToken token,
       string filePath
    )

    Parameters

    token
    The RowToken representing the future row to add the attachment to.
    filePath
    The filesystem path to the file to attach to the row.
    Remarks
    This method is used to add an attachment to a future row returned from the EditOperation.Create method. The RowToken allows a row to be created and the attachment added within the same EditOperation, without the need for chaining.
    Example
    Edit Operation add attachment via RowToken
    // Creates a new feature using the specified editing template and polygon geometry, and adds an attachment to the feature in a single edit operation.
    await QueuedTask.Run(() =>
      {
        //The EditOperation.AddAttachment method to take a RowToken as a parameter 
        //allows you to create a feature, using EditOperation.CreateEx, and add an attachment in one transaction.
    
        EditOperation editOpAttach = new()
        {
          Name = string.Format($@"Create new polygon with attachment in '{currentTemplate.Layer.Name}'")
        };
    
        var attachRowToken = editOpAttach.Create(currentTemplate, polygon);
        editOpAttach.AddAttachment(attachRowToken, @"c:\temp\image.jpg");
    
        //Must be within a QueuedTask
        if (!editOpAttach.IsEmpty)
        {
          //Execute and ExecuteAsync will return true if the operation was successful and false if not
          var result = editOpAttach.Execute();
        }
      });
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also