程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> .NET實例教程 >> 打開保存mxd文件

打開保存mxd文件

編輯:.NET實例教程

用對話框打開文件

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();

              }

   &n 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!");

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved