For the code, refer to the ESRI Chinese community and forget the post...
Directly write the path in the code.
// Merge the set of Layers
ILayer pLayer;
IArray pArray;
PArray = new ArrayClass ();
For (int I = 0; I <this. axMapControl1.LayerCount; I ++)
{
PLayer = this. axMapControl1.get _ Layer (I );
PArray. Add (pLayer );
}
// Define the fields table of the output layer
ITable pTable;
IFeatureLayer pFeatureLayer;
IFeatureClass pFeatureClass;
PLayer = this. axMapControl1.get _ Layer (0 );
PTable = (ITable) pLayer;
PFeatureLayer = (IFeatureLayer) pLayer;
PFeatureClass = pFeatureLayer. FeatureClass;
// Determine whether there are more than two layers
If (this. axMapControl1.LayerCount <2)
{
MessageBox. Show ("Table QI failed ");
Return;
}
// Output file type
IFeatureClassName pFeatureClassName;
IDatasetName pDatasetName;
IWorkspaceName pNewWSName;
PFeatureClassName = new FeatureClassNameClass ();
PFeatureClassName. FeatureType = esriFeatureType. esriFTSimple;
PFeatureClassName. ShapeFieldName = "Shape ";
PFeatureClassName. ShapeType = pFeatureClass. ShapeType;
// Output the shapefile name and position
PNewWSName = new WorkspaceNameClass ();
PNewWSName. WorkspaceFactoryProgID = "esrisponcesfile. ShapefileWorkspaceFactory ";
PNewWSName. PathName = "E: \ data ";
PDatasetName = (IDatasetName) pFeatureClassName;
PDatasetName. Name = "Merge_result ";
PDatasetName. WorkspaceName = pNewWSName;
// Merge Layers
IFeatureClass pOutputFeatClass;
IBasicGeoprocessor pBasicGeop;
PBasicGeop = new BasicGeoprocessorClass ();
POutputFeatClass = pBasicGeop. Merge (pArray, pTable, pFeatureClassName );
// Load the merged layers into the Map
IFeatureLayer pOutputFeatLayer;
POutputFeatLayer = new FeatureLayerClass ();
POutputFeatLayer. FeatureClass = pOutputFeatClass;
POutputFeatLayer. Name = pOutputFeatClass. AliasName;
This. axMapControl1.AddLayer (pOutputFeatLayer as ILayer, 0 );