---Export Function----
private bool ExportFeatureClass(string mdbPath, string inputFeederName, string strInputGSSCode)
{
IEnumLayer pEnumLayer = default(IEnumLayer);
ILayer pLayer = default(ILayer);
IFeatureLayer pFLayer = default(IFeatureLayer);
IFeatureClass pFc = default(IFeatureClass);
IFeatureClassName pINFeatureClassName = default(IFeatureClassName);
IDataset pDataset = default(IDataset);
IDatasetName pInDsName = default(IDatasetName);
IFeatureSelection pFSel = default(IFeatureSelection);
ISelectionSet pSelSet = default(ISelectionSet);
IFeatureClassName pFeatureClassName = default(IFeatureClassName);
IDatasetName pOutDatasetName = default(IDatasetName);
IWorkspaceName pWorkspaceName = default(IWorkspaceName);
IExportOperation pExportOp = default(IExportOperation);
int idx = 0;
idx = 0;
try
{
UID pUID = new UID();
//the UID specifies the interface identifier (GUID)'that represents the type of layer you want returned.'in this case we want an EnumLayer containing all the FeatureLayer objects
pUID.Value = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}";
// Identifies FeatureLayer objects
pEnumLayer = pMap.get_Layers(pUID, true);
pLayer = pEnumLayer.Next();
while ((pLayer != null))
{
pFLayer = pLayer as IFeatureLayer;
pFc = pFLayer.FeatureClass;
//Get the FcName from the featureclass
pDataset = pFc as IDataset;
pINFeatureClassName = pDataset.FullName as IFeatureClassName;
pInDsName = pINFeatureClassName as IDatasetName;
//Get the selection set
pFSel = pFLayer as IFeatureSelection;
pSelSet = pFSel.SelectionSet;
if (pFSel.SelectionSet.Count > 0)
{
//Define the output feature class name
pFeatureClassName = new FeatureClassNameClass();
pOutDatasetName = pFeatureClassName as IDatasetName;
//Split(pOutDatasetName, ".")
if ((pDataset.Name.Contains(".")))
{
pOutDatasetName.Name = pDataset.Name.Substring(pDataset.Name.LastIndexOf(".") + 1, pDataset.Name.Length - pDataset.Name.LastIndexOf(".") - 1);
}
else
{
}
pWorkspaceName = new WorkspaceNameClass();
//C:\Export.mdb
pWorkspaceName.PathName = "C:\\Export\\Export.mdb";
pWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.AccessWorkspaceFactory";
pOutDatasetName.WorkspaceName = pWorkspaceName;
pFeatureClassName.FeatureType = pFc.FeatureType;
pFeatureClassName.ShapeType = pFc.ShapeType;
pFeatureClassName.ShapeFieldName = pFc.ShapeFieldName;
//Export
int x = 0;
pExportOp = new ExportOperation();
pExportOp.ExportFeatureClass(pInDsName, null, pSelSet, null, pOutDatasetName as IFeatureClassName, 0);
}
pLayer = pEnumLayer.Next();
}
//Export table to the generated PGDB
IPropertySet pPropSet = default(IPropertySet);
IWorkspace pWorkspace = default(IWorkspace);
IWorkspaceFactory pWSFactory = default(IWorkspaceFactory);
IFeatureWorkspace pFWS = default(IFeatureWorkspace);
ITable pTable = default(ITable);
ISelectionSet pTabSelSet = default(ISelectionSet);
ITableName pTableName = default(ITableName);
ITableName pOutTableName = default(ITableName);
IQueryFilter pQF = default(IQueryFilter);
if (pExportOp == null)
{
pExportOp = new ExportOperation();
}
pOutTableName = new TableNameClass();
pOutDatasetName = pOutTableName as IDatasetName;
pOutDatasetName.Name = "";
pOutDatasetName.WorkspaceName = pWorkspaceName;
pQF = new QueryFilter();
return true;
}
catch (Exception ex)
{
return false;
MessageBox.Show(ex.Message);
}
}