private void LoadMapDocument2()
{
System.Windows.Forms.OpenFileDialog openFileDialog1;
openFileDialog1 = new OpenFileDialog();
openFileDialog1.Title = "Open Map Document";
openFileDialog1.Filter = "Map Documents (*.mxd)|*.mxd";
openFileDialog1.ShowDialog();
string sFilePath = openFileDialog1.FileName;
If (axMapControl1.CheckMxFile(sFilePath))
{
IArray pArray ;
pArray = axMapControl1.ReadMxMaps(sFilePath,Type.Missing);
int i ;
IMap pMap;
for(i = 0;i<=pArray.Count - 1;i++)
{
pMap = pArray.get_Element(i) as IMap;
if (pMap.Name == "Layers")
{
axMapControl1.MousePointer =
esriControlsMousePointer.esriPointerHourglass;
axMapControl1.LoadMxFile(sFilePath, 0,Type.Missing);
axMapControl1.MousePointer =
esriControlsMousePointer.esriPointerDefault;
break;
}
}
}
else
{
MessageBox.Show(sFilePath + " is not a valid ArcMap document");
return;
}
}