I am trying to use Merge_Management Geoprocessing tool in arcobject, I want these tool to use layers named "HT Overhead Line" and "HT Underground Line" and create the output out.shp.
Below is the code I am trying which is not working.
IMxDocument mxdoc = ArcMap.Application.Document as IMxDocument; IMap map = mxdoc.FocusMap; if (map.Layer[0] == null) { return; } IGeoProcessor2 gp = new GeoProcessorClass(); gp.AddOutputsToMap = true; gp.OverwriteOutput = true; IVariantArray parameters = new VarArrayClass(); IGpValueTableObject vt = new GpValueTableObjectClass(); for (int i = 0; i < map.LayerCount; i++) { if (map.Layer[i].Name == "HT Overhead Line") { ILayer HTOverheadLine = map.Layer[i]; IFeatureLayer fl1 = new FeatureLayerClass(); fl1 = HTOverheadLine as IFeatureLayer; IFeatureClass inFeature1 = fl1.FeatureClass; vt.SetColumns(1); object obj1 = inFeature1; vt.AddRow(obj1); } else { if (map.Layer[i].Name == "HT Underground Line") { ILayer HTUndergroundLine = map.Layer[i]; IFeatureLayer fl2 = new FeatureLayerClass(); fl2 = HTUndergroundLine as IFeatureLayer; IFeatureClass inFeature2 = fl2.FeatureClass; vt.SetColumns(2); object obj2 = inFeature2; vt.AddRow(obj2); } } } parameters.Add(vt); parameters.Add(@"OutPath\Out.shp"); gp.Execute("Merge_management", parameters, null);