openFileDialog打开加载多个文件

 OpenFileDialog open = new OpenFileDialog();
            open.Multiselect=true;//可以选择多个选项
            open.Title = "选择需要加载的地里数据文件";
            open.Filter = "Shape格式文件(*.shp)|*.shp";
            if (open.ShowDialog ()== DialogResult.OK)
            {
                foreach (string Wenjian in open.FileNames)
                {
                    //选择了shape文件后
                    string pathName = System.IO.Path.GetDirectoryName(Wenjian);
                    string fileName = System.IO.Path.GetFileNameWithoutExtension(Wenjian);
                    //axmapcontrol1加载地图
                    axMapControl1.AddShapeFile(pathName, fileName);
                    //鹰眼加载地图
                    //axMapControl2.ClearLayers();//鹰眼视图是否更换
                    axMapControl2.AddShapeFile(pathName, fileName);
                    axMapControl2.Extent = axMapControl2.FullExtent;//显示全图
                }
            }

你可能感兴趣的:(c#)