AnsweredAssumed Answered

Getting Access to Feature Classes in File GDB without a Dataset?

Question asked by belowzero8 on May 7, 2013
Latest reply on May 7, 2013 by belowzero8
I've got a script that works with many different forms of File GDBs.  Sometimes they have datasets and sometimes they dont.  For the ones that have datasets, I have the working code:

C# IWorkspaceFactory wsFact = new FileGDBWorkspaceFactoryClass(); IWorkspace ws = wsFact.OpenFromFile(database, 0); IEnumDataset enumDS = ws.get_Datasets(esriDatasetType.esriDTFeatureDataset); IFeatureDataset ds = (IFeatureDataset)enumDS.Next(); IEnumDataset enumFC = ds.Subsets; IDataset currFC = enumFC.Next(); FeatureClass fc = (FeatureClass)currFC;


But, when the database doesn't have a dataset and it hits the 5th line it throws an error since enumDS.Next() is null.  I've tried to chance the esriDatasetType to esriDTFeatureClass, but that doesn't work.  I've also tried using the GeoProcessor (which I would prefer not to), but the ListFeatureClasses returns a blank string.

I'm sure this has a simple solution, but I just cannot find it.

Outcomes