Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I get a Table [Streets] not found when I try to convert a shapefile to a geodatabase.

I'm thinking I'll try setting the spatial reference like in this post,

But I'm not sure what the steps are to get a GeometryDefEdit from my converter code

IWorkspaceName pInShpWorkspaceName = new WorkspaceNameClass() as IWorkspaceName;
pInShpWorkspaceName.PathName = shapeFileDirectory;
pInShpWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory";
IFeatureClassName pFCName = new FeatureClassNameClass() as IFeatureClassName;
IDatasetName pShpDatasetName = pFCName as IDatasetName;
pShpDatasetName.Name = shapeFileName;//this is your input file 
pShpDatasetName.WorkspaceName = pInShpWorkspaceName;
IName sourceName = (IName)pFCName;
IFeatureClass sourceFeatureClass = (IFeatureClass)sourceName.Open();
IFields sourceFields = sourceFeatureClass.Fields;

IWorkspaceName pWorkspaceName = new WorkspaceNameClass() as IWorkspaceName;
pWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.FileGDBWorkspaceFactory";
pWorkspaceName.PathName = GDBPath; //output file 
IFeatureClassName pOutputFC = new FeatureClassNameClass();
IDatasetName pDataSetName = pOutputFC as IDatasetName;
pDataSetName.WorkspaceName = pWorkspaceName;
pDataSetName.Name = "Streets";
IFeatureDataConverter pShpToFc = new FeatureDataConverterClass();

pShpToFc.ConvertFeatureClass(pFCName, null, null, pOutputFC, null, sourceFields, "", 1000, 0);

Also is there anything else I should try ?

I guess it was the 5th Param into ConvertFeatureClass, but unfortunately it didn't make any difference.


So I did the following operation:

ConvertFieldName(sourceFields, "CITY", "CITY3"); //change column name from city to city3

void ConvertFieldName(IFields fields, string oldname, string newname)
  if (string.IsNullOrEmpty(oldname)) return;
  if (newname == oldname) return;
  List<string> fieldnames = GetFieldNames(fields);

  IFieldsEdit editfields = fields as IFieldsEdit;
  int index = editfields.FindField(oldname);
  if (index != -1)
    IField field = editfields.get_Field(index);
    IFieldEdit addresspd = field as IFieldEdit;
    addresspd.Name_2 = newname;
    addresspd.AliasName_2 = newname;

And also I try this: (Change column name, and change it back)

ConvertFieldName(sourceFields, "CITY", "CITY3"); 
ConvertFieldName(sourceFields, "CITY3", "CITY"); 

Seems insane, I know, but for some reason, doing these operations (either changing or changing back and forth) allowed the GDB file to be created. I guess the code was cleaning up a resource or something, which allowed for the GDB creation.

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.