SmallSheeper
2016-04-21 03:29 浏览 1.7k

AE中添加shp文件的问题!

这段代码有问题吗?可以生成解决方案,但是还是不能加载shp文件啊。报错显示

图片说明

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.IO;

namespace test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void addShapeFile()
{
System.Windows.Forms.OpenFileDialog openFileDialog;
openFileDialog = new OpenFileDialog();
openFileDialog.Title = "打开图层文件";
openFileDialog.Filter = "map documents(*.shp)|*.shp";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
FileInfo fileInfo = new FileInfo(openFileDialog.FileName);
String path = fileInfo.Directory.ToString();
String fileName = fileInfo.Name.Substring(0, fileInfo.Name.IndexOf("."));
try
{
axMapControl1.AddShapeFile(path, fileName);
}
catch (Exception e)
{
MessageBox.Show("添加图层失败!!!" + e.ToString());
}
}
}
private void button1_Click(object sender, EventArgs e)
{
addShapeFile();

    }
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

相关推荐