1

I want to add an existing feature class to an existing feature dataset. Both the feature class and the dataset have the same coordinate system, I searched over the net but only assistance I found was to create a new feature class in a feature dataset (I tried that and it worked). According my understanding I tried using IDatasetContainer but it's not working. Here is the code:

IFeatureDataset featureDataset1 = featureWorkspace.OpenFeatureDataset("featureDataset1");
IDataset datasetFcTenActors = fc_tenActors as IDataset;  // fc_tenActors is my feature class to add
IDatasetContainer container = featureDataset1 as IDatasetContainer;
container.AddDataset(datasetFcTenActors);
5
  • @DevdattaTengshe : thanks but I am able to do the same using arcmaps by simply copying the feature class and pasting into the feature dataset. Also there is already a line feature class present in the feature dataset which I created but not copy.
    – Aditya
    Commented Jan 30, 2014 at 15:55
  • It doesn't change when I drag and drop but changes when I copy paste. I want to code the drag and drop into feature dataset.
    – Aditya
    Commented Jan 30, 2014 at 16:08
  • ok.. Got it. I was misunderstanding your question. Commented Jan 30, 2014 at 16:10
  • What do you mean when you say that the code does not work? Commented Jan 30, 2014 at 16:13
  • @DevdattaTengshe : I tried the above code and gave COM exception "Exception from HRESULT: 0x8004022D" on the line - container.AddDataset(datasetFcTenActors);
    – Aditya
    Commented Jan 30, 2014 at 16:55

2 Answers 2

1

Maybe the IFeatureDataConverter2.ConvertFeatureClass Method does what you need:

http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#/d/0025000002w5000000.htm

It takes a source Featureclass Name and an Output featuredataset Name as Parameter.

0

The IDatasetContainer interface lets you move datasets between FeatureDatasets and Workspaces—both objects implement the interface. However, It should be used to move datasets between Feature Datasets within a single workspace, but not between workspaces. If you situation doesn't meet this precondition, follow Chris suggestion (IFeatureDataConverter2). Note that when moving feature classes into a feature dataset, the spatial reference of the source feature class must match the spatial reference of the target feature dataset.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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