I have a featureclass with Arcobjects that came from a Shapefile and I wish to import it into a geodatabase. I have the geodatabase connection, I just don't know how to load the feature class to a Geodatabase. Any help would be amazing!

I'm looking for a code example seeing I can't find it by googling. Hopefully in C#, but I don't mind reading through VB if needed.


I wanted to add the Answer thanks to George so here is a code snippet with comments.

 ESRI.ArcGIS.Geodatabase.IWorkspace pWorkspace;
        ESRI.ArcGIS.Geodatabase.IWorkspaceFactory pWorkspaceFactory;
        ESRI.ArcGIS.Geodatabase.IFeatureWorkspace SdeFeatureWorkspace;

        pWorkspaceFactory = new FileGDBWorkspaceFactory();
        pWorkspace = pWorkspaceFactory.OpenFromFile(@"C:\tests\test.gdb", 0); //Opens the Geodeabase and creates a connection.
        SdeFeatureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)pWorkspace;

        IWorkspaceFactory workspaceFactoryShape = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass(); //creates a shape factory to pull the shape and create the feature class.
        IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspaceFactoryShape.OpenFromFile(@"C:\Users\Desktop\Newfolder", 0); //Opens the Shape file.
        IFeatureClass featureClass = featureWorkspace.OpenFeatureClass("al012009.001_5day_lin"); //opens the featurclass from the shapefile

        SdeFeatureWorkspace.CreateFeatureClass("al012009001_5day_linnn", featureClass.Fields, featureClass.CLSID, featureClass.EXTCLSID, featureClass.FeatureType, featureClass.ShapeFieldName, null); //creates a feature class in the geodb.

        Geoprocessor gp = new Geoprocessor(); //starts a GEOprocess.
        gp.SetEnvironmentValue("workspace", @"C:\Tests\test.gdb"); //sets the geodb to use

        ESRI.ArcGIS.DataManagementTools.Append  append = new ESRI.ArcGIS.DataManagementTools.Append(); //this tool uploads the feature class
        append.inputs = featureClass;
        append.target = @"C:\tests\test.gdb\al012009001_5day_linnn";

        gp.Execute(append, null); 

3 Answers 3


Given the details, you can construct a new feature class based on the details of your in memory object (IFields, etc)

You can view examples in the .NET ArcObjects documentation (http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//0049000000pz000000)

After creating it, you can insert each object. This is a painful/ineffective way, but it should work.

Another option that you have is to use the IGeoprocessor interface and IGPProcess, and execute a tool like append.


  • 1
    No problem. You should check waterboys response. It's also a manner to insert a featureclass inside a geodatabase. Commented Aug 3, 2010 at 2:15

I think this could be accomplished more simply by using the Copy method of the IDataset interface.

Once you have the existing feature class (featureClass in your example) and destination workspace defined (pWorkspace in your example)

Use the following where "CopyName" can be changed to whatever you want the new feature class to be named ("al012009001_5day_linnn" for your example)

ESRI.ArcGIS.Geodatabase.IDataset dataset = featureClass;
dataset.Copy("CopyName", pWorkspace);

I have sample code using append geoprocessing for copying feature selection to other geodatabase.

        Geoprocessor GP = new Geoprocessor();

        SelectLayerByAttribute SelectByAttribute = new SelectLayerByAttribute();

        SelectByAttribute.in_layer_or_view = "Digit";
        SelectByAttribute.selection_type = "NEW_SELECTION";
        SelectByAttribute.where_clause = filter;
        RunTool(GP, SelectByAttribute, null);

        Append app = new Append();
        app.inputs = SelectByAttribute.in_layer_or_view;
        app.target = @"D:\Temp\Inventory.mdb\Data\QC1";
        app.schema_type = "TEST";
        RunTool(GP, app, null);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.