1 OpenFileDialog openFileDialog1 = new OpenFileDialog(); 2 openFileDialog1.Filter = "lyr文件(*.lyr)|*.lyr"; 3 openFileDialog1.InitialDirectory = @"d:\data"; 4 openFileDialog1.Multiselect = false; 5 DialogResult pDialogResult = openFileDialog1.ShowDialog(); 6 if (pDialogResult != DialogResult.OK) 7 return; 8 string pFileName = openFileDialog1.FileName; 9 axMapControl1.AddLayerFromFile(pFileName); 10 //axMapControl1.ActiveView.Refresh(); 11 axMapControl1.Extent = axMapControl1.FullExtent; 12 ILayer player = axMapControl1.get_Layer(0); 13 IFeatureLayer pfeatlayer = player as IFeatureLayer; 14 IGeoFeatureLayer pgeo=pfeatlayer as IGeoFeatureLayer; 15 IFeatureRenderer ren= pgeo.Renderer as IFeatureRenderer; 16 IPersistStream stream = ren as IPersistStream; 17 18 ESRI.ArcGIS.esriSystem.IMemoryBlobStream pMemoryBlobStream = new ESRI.ArcGIS.esriSystem.MemoryBlobStreamClass(); 19 20 IObjectStream pObjectStream = new ObjectStreamClass(); 21 pObjectStream.Stream = pMemoryBlobStream; 22 IPersistStream pPersistStream = (IPersistStream)ren; 23 pPersistStream.Save((IStream)pObjectStream, 0); 24 pMemoryBlobStream.SaveToFile(@"d:\a.render");
程序还出现一个错误,修改Ae的Dll引用的属性“嵌入式互操作程序”为false。