I have never done this using the .NET SDK, but I have used this python script in the past:
import arcpy, os, sys
arcpy.env.overwriteOutput = True
def extract_attachments(out_ws, table, blob_field, filename_fld):
'''
Code adopted from "Another GIS Blog"
http://anothergisblog.blogspot.nl/2012/06/working-with-blob-data-at-101-arcpyda.html
""" Exports all attachments from a geodatabase to a new location """
Required:
out_ws -- location for attachments
table -- table or feature class containing attachment info
blob_field -- field containing attachment files
filename_fld -- field name containing file name
'''
# make sure out_ws exists, if not create
if not os.path.exists(out_ws):
os.makedirs(out_ws)
# search cursor
c = 0
with arcpy.da.SearchCursor(table, ['REL_OBJECTID', blob_field, filename_fld]) as rows:
for row in rows:
roid, binRep, fileName = row
if binRep:
out_file = os.path.join(out_ws, 'OID_' + '_'.join(map(str, [roid, fileName])))
open(out_file, 'wb').write(binRep.tobytes())
c += 1
arcpy.AddMessage('Exported {0} attachments to: "{1}"'.format(c, out_ws))
return
if __name__ == '__main__':
# run as script tool
extract_attachments(*sys.argv[1:])
Does this have to be done in ArcObjects?