public void UpdateAttachment( Attachment updatedAttachment )
Public Sub UpdateAttachment( _ ByVal updatedAttachment As Attachment _ )
Parameters
- updatedAttachment
- An attachment for which all properties have been modified as desired.
public void UpdateAttachment( Attachment updatedAttachment )
Public Sub UpdateAttachment( _ ByVal updatedAttachment As Attachment _ )
Exception | Description |
---|---|
ArcGIS.Core.Data.Exceptions.GeodatabaseAttachmentNotEnabledException | The table or feature class has not been enabled for attachment creation. |
System.ArgumentNullException | updatedAttachment is null. |
System.ArgumentException | updatedAttachment's attachment ID is invalid. |
ArcGIS.Core.Data.Exceptions.GeodatabaseException | A geodatabase-related exception has occurred. |
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); } } } } } }); }
Target Platforms: Windows 11, Windows 10