GIS

ArcObject : xmd 맵문서 저장 -C#

조심이 2010. 12. 6. 16:03
반응형

9.3.1 기준
using ESRI.ArcGIS.Carto;
 
public void MxdSave()
        {
            try
            {
                IMapControl3 m_mapControl;
                
               //pMapCtrl 맵컨트롤 이름
                m_mapControl = (IMapControl3)pMapCtrl.Object;

                  //execute Save Document command
                if (m_mapControl.CheckMxFile(m_mapControl.DocumentFilename))
                {
                    //create a new instance of a MapDocument
                    IMapDocument mapDoc = new MapDocumentClass();
                    mapDoc.Open(m_mapControl.DocumentFilename, string.Empty);

                    //Make sure that the MapDocument is not readonly
                    if (mapDoc.get_IsReadOnly(m_mapControl.DocumentFilename))
                    {
                        MessageBox.Show("맵문서가 읽기전용입ㄴ디ㅏ..");
                        mapDoc.Close();
                        return;
                    }

                    //Replace its contents with the current map
                    mapDoc.ReplaceContents((IMxdContents)m_mapControl.Map);

                    //save the MapDocument in order to persist it
                    mapDoc.Save(mapDoc.UsesRelativePaths, false);

                    //close the MapDocument
                    mapDoc.Close();
                }
            }
            catch
            {
               
            }


        }

반응형