问题描述
下面这个是我写的加载SHP文件,在对话框里面可以多选SHP文件但是加载的时候只能加载一个,不知道怎么同时加载对话框中选中的多个SHP文件?另外,怎样把同时加载的点线面SHP文件,另存为MXD文件?希望有心人指导,最好有源码。谢谢!try{OpenFileDialogopenFileDialog=newOpenFileDialog();openFileDialog.Multiselect=true;//能同时选择对话框里面的多个文件openFileDialog.Title="打开地图文档!";openFileDialog.Filter="mapdocument(*.shp)|*.shp";openFileDialog.ShowDialog();stringfilePath=openFileDialog.FileName;FileInfofileInfo=newFileInfo(filePath);stringpath=filePath.Substring(0,filePath.Length-fileInfo.Name.Length);MapCtrl.AddShapeFile(path,fileInfo.Name);}catch(Exceptiona){MessageBox.Show("加载图层失败!"+e.ToString());}
解决方案
解决方案二:
OpenFileDialogOpenLyrFile=newOpenFileDialog();OpenLyrFile.Multiselect=true;OpenLyrFile.Title="打开Lyr";OpenLyrFile.InitialDirectory="C:";OpenLyrFile.Filter="lyr文件(*.lyr)|*.lyr";if(OpenLyrFile.ShowDialog()==DialogResult.OK){string[]Names=OpenLyrFile.FileNames;foreach(stringsinNames){axMap.AddLayerFromFile(s);}//地图文档全图显示axMap.Extent=axMap.FullExtent;