Select to view content in your preferred language

AddAttachment

1900
1
07-27-2011 11:45 AM
CraigPerreault
Deactivated User
I am trying to add an attachment (.jpg file) to a feature.  Does anyone have a simple code example?
featureLayer.AddAttachment(theNewObjectID, stream, ofdWorksheet.File.Name, null, null);


I would also like to implement: AttachmentResult and Exception
0 Kudos
1 Reply
DominiqueBroux
Esri Frequent Contributor
I would also like to implement: AttachmentResult and Exception .


The two last arguments of AddAttachments are callbacks giving you the result and the exception.

You can use them with code like:

var callback = (Action<AttachmentResult>)delegate(AttachmentResult result)
{
 MessageBox.Show("Added attachment to " + result.ObjectID);
};
 
var errorCallback = (Action<Exception>)delegate(Exception result)
{
 MessageBox.Show("Error adding attachment : " + result.Message);
};
 
featureLayer.AddAttachment(theNewObjectID, stream, ofdWorksheet.File.Name, callback, errorCallback);
0 Kudos