private void AddShapeFileLayer(string path, string fileName)
{
try
{
// Create a new ShapefileWorkspaceFactory object and
// open a shapefile folder - the path works with standard 9.3 installation
IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactory();
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)
workspaceFactory.OpenFromFile(path, 0);
// Create a new FeatureLayer and assign a shapefile to it
IFeatureLayer featureLayer = new ESRI.ArcGIS.Carto.FeatureLayer();
featureLayer.FeatureClass = featureWorkspace.OpenFeatureClass(fileName);
ILayer layer = (ILayer)featureLayer;
layer.Name = featureLayer.FeatureClass.AliasName;
// Add the Layer to the focus map
IMap map = ArcMap.Document.FocusMap;
map.AddLayer(layer);
}
catch (Exception e)
{
Log.WriteLine("AddShapeFileLayer: " + e.Message);
}
}