Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

When a user loads an mxd, I am getting the IWorkspace object from the featurelayer's dataset:

IFeatureClass featClass = (IFeatureClass)featLayer.FeatureClass;
IDataset dataSet = (IDataset)featClass.FeatureDataset;
IWorkspace workSpace = (IWorkspace)dataSet.Workspace;

But this obviously does not work if the user has a layer from a file geodatabase (dataset is null).

I can check to see if it's a gdb layer but nothing in the featurelayer or its featureclass tells me the source of the gdb.

How do I go about setting the workspace object to a featurelayer that comes from a gdb?

share|improve this question
    
IS THIS RESOLVED? –  ujjwalesri Jun 30 '11 at 5:22
add comment

1 Answer

up vote 3 down vote accepted

Change the line

IDataset dataSet = (IDataset)featClass.FeatureDataset;

to

IDataset dataset = (IDataset)featClass;
share|improve this answer
    
Simple as that. QI the featclass to the dataset gives me the fgdb path in its workspace property. Thank you very much. –  SteveC Jun 30 '11 at 15:14
add comment

Your Answer

 
discard

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

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