ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data Namespace / Row Class / UpdateAttachment Method
An attachment for which all properties have been modified as desired.
Example Version

UpdateAttachment Method (Row)
Updates the properties of an existing attachment fetched using GetAttachment with new values This method must be called on the MCT. Use QueuedTask.Run.
Syntax
public void UpdateAttachment( 
   Attachment updatedAttachment
)

Parameters

updatedAttachment
An attachment for which all properties have been modified as desired.
Exceptions
ExceptionDescription
The table or feature class has not been enabled for attachment creation.
updatedAttachment is null.
updatedAttachment's attachment ID is invalid.
A geodatabase-related exception has occurred.
Example
Updating Attachments
public async Task UpdatingAttachments()
{
    await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
    {
        using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde"))))
        using (FeatureClass landUseCaseFeatureClass = geodatabase.OpenDataset<FeatureClass>("LocalGovernment.GDB.LandUseCase"))
        {
            QueryFilter filter = new QueryFilter { WhereClause = "CASETYPE = 'Rezoning'" };

            using (RowCursor landUseCursor = landUseCaseFeatureClass.Search(filter, false))
            {
                while (landUseCursor.MoveNext())
                {
                    using (Feature rezoningUseCase = (Feature)landUseCursor.Current)
                    {
                        IReadOnlyList<Attachment> rezoningAttachments = rezoningUseCase.GetAttachments();
                        IEnumerable<Attachment> filteredAttachments = rezoningAttachments.Where(attachment => !attachment.GetName().Contains("rezoning"));

                        foreach (Attachment attachmentToUpdate in filteredAttachments)
                        {
                            attachmentToUpdate.SetName(attachmentToUpdate.GetName().Replace(".pdf", "Rezoning.pdf"));
                            rezoningUseCase.UpdateAttachment(attachmentToUpdate);
                        }
                    }
                }
            }
        }
    });
}
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also