ArcGIS 读写lyr层文件

原文arcengine C# 读写lyr(转)

写lyr   

IFeatureLayer LineLayer = axMapControl1.get_Layer(0) as IFeatureLayer;
ILayerFile layerFile = new LayerFileClass();
//create a new layer file
layerFile.New(saveFileDialog.FileName);
//attach the layer file with the actual layer
layerFile.ReplaceContents((ILayer)LineLayer);
// savee the layer file
layerFile.Save();

 

读取层文件

public void ReadLyr(string pFileName)
{
    try
    {
        IMapControl2 myAddLayerMap = new MapControlClass();
        myAddLayerMap.AddLayerFromFile(pFileName, 0);
        this.axMapControl1.AddLayer(myAddLayerMap.get_Layer(0));
    }
    catch (Exception ex)
    {
        throw new Exception(ex.Message);
    }
}

 

 

 

posted @ 2016-09-25 11:01  wenglabs  阅读(5393)  评论(0编辑  收藏  举报