打开保存mxd文件

用对话框打开文件

openFileDialog1.Title = "Open Map Document";

              openFileDialog1.Filter = "Map Documents (*.mxd)|*.mxd";

              openFileDialog1.ShowDialog();

 

              // Exit if no map document is selected

              string sFilePath = openFileDialog1.FileName;

              if (sFilePath == "")

              {

                   return;

              }

 

用对话框保存文件

saveFileDialog1.Title = "Save Map Document As";

              saveFileDialog1.Filter = "Map Documents (*.mxd)|*.mxd";

              saveFileDialog1.ShowDialog();

 

              //Exit if no map document is selected

              string sFilePath = saveFileDialog1.FileName;

              if (sFilePath == "")

              {

                   return;

              }

 

              if (sFilePath == m_MapDocument.DocumentFilename)

              {

                   //Save changes to the current document

                   SaveDocument();

              }

              else

              {

                   //SaveAs a new document with relative paths

                   m_MapDocument.SaveAs(sFilePath, true, true);

                   //Open document               

                   OpenDocument((sFilePath));

                   MessageBox.Show("Document saved successfully!");

              }

显示打开的MXD地图

              //Create a new map document

              m_MapDocument = new MapDocumentClass();

              //Open the map document selected

              m_MapDocument.Open(sFilePath,"");

              //Set the PageLayoutControl page layout to the map document page layout

              axPageLayoutControl1.PageLayout = m_MapDocument.PageLayout;

              txtMapDocument.Text = m_MapDocument.DocumentFilename;

保存文件后显示再PAGlayout control上显示保存后的MXD文件

              //Check that the document is not read only

              if (m_MapDocument.get_IsReadOnly(m_MapDocument.DocumentFilename) == true)

              {

                   MessageBox.Show("This map document is read only!");

                   return;

              }

              //Save with the current relative path setting

              m_MapDocument.Save(m_MapDocument.UsesRelativePaths,true);

              MessageBox.Show("Changes saved successfully!");

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值