Exporting to a feature dataset within a file geodatabase

Discussion created by shaunrconway on Feb 17, 2011
Latest reply on Feb 17, 2011 by shaunrconway

I have the attached code which accepts a feature class as a parameter and saves a copy of this feature class as a new feature class in a file geodatabase. My problem is that I would like to save the exported feature class to a specific feature dataset within the target file geodatabase.

Can someone please share how this is accomplished?

thanks in advance :)

Dim pInFeatureClassName As IFeatureClassName
Dim pDataSet As IDataset
Dim pInDsName As IDatasetName
Dim pFSel As IFeatureSelection
Dim pSelSet As ISelectionSet
Dim pFeatureClassName As IFeatureClassName
Dim pOutDatasetName As IDatasetName
Dim pWorkspaceName As IWorkspaceName
Dim pExportOp As IExportOperation
Dim pFeatureLayer As IFeatureLayer

'Get the Featureclassname from the featureclass
Set pDataSet = pFC
Set pInFeatureClassName = pDataSet.FullName

'Define the output featureclass
'give it the name of the input feature class + exp
Set pFeatureClassName = New FeatureClassName
Set pOutDatasetName = pFeatureClassName
pOutDatasetName.Name = "scenario_" & frmSaveScenario.tbScenarioName & "_" & sType
Set pWorkspaceName = New WorkspaceName
pWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.FileGDBWorkspaceFactory"
pWorkspaceName.PathName = "\\tempest\shared\GIS\Community Development\Redistricting\Census\2000_Census.gdb"

Set pOutDatasetName.WorkspaceName = pWorkspaceName

'Give the output shapefile the same props as the input dataset
pFeatureClassName.FeatureType = pFC.FeatureType
pFeatureClassName.ShapeType = pFC.ShapeType
pFeatureClassName.ShapeFieldName = pFC.ShapeFieldName
'pFeatureClassName.FeatureDatasetName = pFC.FeatureDataset

Set pInDsName = pInFeatureClassName

'Export selected features
Set pExportOp = New ExportOperation
pExportOp.ExportFeatureClass pInDsName, Nothing, Nothing, Nothing, pOutDatasetName, 0