# How can I permanently reorder fields in a feature class programmatically with ArcObjects, VB.Net?

Would someone be able to share the logistics on how to permanently programmatically reorder fields in a feature class with ArcObjects, VB.Net.

I want to be able to do this in the geodatabase not in the IOrderedLayerFields Interface of the Carto assembly.

-
I think it's the same as with geoprocessing, you need to drop and re-create the table/feature class completely. Is that acceptable? –  blah238 Jan 25 '13 at 19:51
I was hoping for a more "elegant" solution. –  Jakub Jan 25 '13 at 19:58
I don't think there is one, but people have certainly asked for this before: ideas.arcgis.com/ideaView?id=0873000000087wg –  blah238 Jan 25 '13 at 20:41
–  blah238 Jan 25 '13 at 20:43
They gave us "rename field" in 10.1 but not reordering. Maybe in 10.2 and \$12,000 in maintenance fees later. I can manage the "drop and re-create" solution. I guess we can close this post. –  Jakub Jan 25 '13 at 21:27

Even with ArcObjects, the only way to permanently reorder fields in a table or feature class is to drop the table completely and re-create it. There is a very popular ArcGIS Idea to get this implemented, so vote for it if you want to see such a feature.

-

I cannot help with ArcObjects code but your question seems to be just after the logic.

I recommend basing your logic on the Answer to How to re-order fields permanently using ArcGIS Make Query Table tool?

-

This is possible in python using FeatureClasstoFeatureClass with Fieldmappings. You can also rename fields at the same time.

So if you have a Featureclass with FIELD3,FIELD2,FIELD1 and you want the result to be FIELD1,F2,F3 then the following code should accomplish this.

arcpy.env.overwriteOutput = True

input_fpath = "c:\\gis\\Geodatabases\\temp.gdb\\in_fc"

output_dpath = "c:\\gis\\Geodatabases\\temp.gdb"
output_fname = "out_fc"

fms = arcpy.FieldMappings()

fm = arcpy.FieldMap()

fm = arcpy.FieldMap()
of = fm.outputField
of.name = "F2"
of.aliasName = "F2"
fm.outputField = of

fm = arcpy.FieldMap()
of = fm.outputField
of.name = "F3"
of.aliasName = "F3"
fm.outputField = of