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();
}
/// <summary>
/// 读取层文件
/// </summary>
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);
}
}