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);
    }
}

 

 

 

转载自:https://blog.csdn.net/weixin_34326429/article/details/86350316

You may also like...