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