分享给有需要的人,代码质量勿喷。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ESRI.ArcGIS.Carto;
namespace OpenMxd
{
public partial class Form1 : Form
{
public Form1()
{
//很重要的一句话
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
InitializeComponent();
}
private void openMxdToolStripMenuItem_Click(object sender, EventArgs e)
{
IMapDocument xjMxdMapDocument = new MapDocumentClass();
OpenFileDialog xjMxdOpenFileDialog = new OpenFileDialog();
xjMxdOpenFileDialog.Filter = "地图文档(*.mxd)|*.mxd";
if (xjMxdOpenFileDialog.ShowDialog() == DialogResult.OK)
{
string xjmxdFilePath = xjMxdOpenFileDialog.FileName;
if (axMapControl1.CheckMxFile(xjmxdFilePath))
{
axMapControl1.Map.ClearLayers();
axMapControl1.LoadMxFile(xjmxdFilePath);
}
}
axMapControl1.ActiveView.Refresh();
}
}
}
代码下载地址:C#+ArcEngine 打开mxd地图文档(窗体+代码)
优快云下载需要的积分太多【系统自动调整,我也没办法】。
分享在百度网盘了,链接失效可联系 lljydyx@126.com。
链接:https://pan.baidu.com/s/1P0wi5WxPiHp_lXq35W_5GQ
提取码:vr35