There is a really cool thing called the ArcObjects API. Granted, I can't hold it against anyone who tries to make sense of the ArcObjects .NET API, because you can't find anything without expanding, expanding, expanding.. This is a Java example, so sorry for that.I opened eclipse and used the new project wizard to create a console application. Then I used the sample ArcGIS snippets for listing feature classes of a FGDB workspace.Notice in listFeatureclass, they use the concrete class FileGeodatabaseWorkspaceFactory to create new FileGeodatabaseWorkspaceFactory.Notice in listFeatureclass2, we're using the WorkspaceFactory class .. what? What kind of black magic is that?Give them a try, pass in a file name of "c:\\myfgdb.gdb" and see what happens.
public static void listFeatureclass(String file) throws java.net.UnknownHostException, java.io.IOException {
com.esri.arcgis.datasourcesGDB.FileGDBWorkspaceFactory factory = new com.esri.arcgis.datasourcesGDB.FileGDBWorkspaceFactory();
com.esri.arcgis.geodatabase.IWorkspace workspace = factory.openFromFile(file, 0);
com.esri.arcgis.geodatabase.IEnumDataset enumDataset = workspace.getDatasets(com.esri.arcgis.geodatabase.esriDatasetType.esriDTFeatureClass);
com.esri.arcgis.geodatabase.IDataset ds = null;
ds = enumDataset.next();
while(ds != null){
com.esri.arcgis.geodatabase.IFeatureClass fClass = new com.esri.arcgis.geodatabase.IFeatureClassProxy(ds);
int fCount = fClass.featureCount(null);
System.out.println("FeatureClass "+ fClass.getAliasName() +" has "+fCount+ " features.");
ds = enumDataset.next();
}
}
public static void listFeatureclass2(String file) throws java.net.UnknownHostException, java.io.IOException {
com.esri.arcgis.geodatabase.WorkspaceFactory factory = new com.esri.arcgis.geodatabase.WorkspaceFactory(new com.esri.arcgis.datasourcesGDB.FileGDBWorkspaceFactory());
com.esri.arcgis.geodatabase.IWorkspace workspace = factory.openFromFile(file, 0);
com.esri.arcgis.geodatabase.IEnumDataset enumDataset = workspace.getDatasets(com.esri.arcgis.geodatabase.esriDatasetType.esriDTFeatureClass);
com.esri.arcgis.geodatabase.IDataset ds = null;
ds = enumDataset.next();
while(ds != null){
com.esri.arcgis.geodatabase.IFeatureClass fClass = new com.esri.arcgis.geodatabase.IFeatureClassProxy(ds);
int fCount = fClass.featureCount(null);
System.out.println("FeatureClass "+ fClass.getAliasName() +" has "+fCount+ " features.");
ds = enumDataset.next();
}
}