ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data Namespace / Attachment Class / SetName Method
The name of the attached document.
Example Version

SetName Method (Attachment)
Sets the file name of the attached document. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
public void SetName( 
   string attachmentName
)

Parameters

attachmentName
The name of the attached document.
Exceptions
ExceptionDescription
A geodatabase-related exception has occurred.
This method or property must be called within the lambda passed to QueuedTask.Run
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