Quantcast
Channel: Forums - ArcObjects SDKs
Viewing all articles
Browse latest Browse all 1374

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

$
0
0
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:

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.

Viewing all articles
Browse latest Browse all 1374

Trending Articles