I have a shapefile (Point) and a table which I join using the following code.
public ITable JoinLayer_Table(IFeatureLayer pFeatLayer, IStandaloneTable pStTable)
{
IDisplayTable pDispTable;
IFeatureClass pFCLayer;
ITable pTLayer;
pDispTable = (IDisplayTable)pFeatLayer;
pFCLayer = (IFeatureClass)pDispTable.DisplayTable;
pTLayer = (ITable)pFCLayer;
IDisplayTable pDispTable2;
ITable pTTable;
pDispTable2 = (IDisplayTable)pStTable;
pTTable = pDispTable2.DisplayTable;
IRelationshipClass pRelClass;
IMemoryRelationshipClassFactory pMemRelFact = new MemoryRelationshipClassFactory();
pRelClass = pMemRelFact.Open("TabletoLayer", (IObjectClass)pTLayer, "HouseNo", (IObjectClass)pTTable, "UNIT_ID", "forward", "backward", esriRelCardinality.esriRelCardinalityOneToMany);
IRelQueryTableFactory pRelQueryTableFact = new RelQueryTableFactory();
ITable pRelQueryTab = (ITable)pRelQueryTableFact.Open(pRelClass, true, null, null, "", true, true);
return pRelQueryTab;
}
The join results is an ITable.
Now I need to make a shapefile from the Join results and add it to the TOC in ArcMap. How can I do this?
Any code example would be greatly appreciated.
Actually I wanted to join two shapefiles (a point shapefile and a polygon shapefile) and get a point shapefile for the JOIN results, but could not do that. So that's why I have a point shapefile and the corresponding dbf of the polygon shapefile to create the Join.
Any help on this also would be greatly appreciated.
Best Answer
You could try using ESRI.ArcGIS.GeoDatabaseUI.IExportOperation.
In the code below srcTable is your pRelQueryTab.
You need to set up source and destination dataset names.
Not sure if it will work but I use similar code to export layers with an existing join.