Several ways to save Mxd files in AE

Several ways to save Mxd files in AE

The document object is mainly completed by the IMapdocument and IMxdContents interfaces. IMapDocument defines the methods and attributes for manipulating and managing document objects, including reading, writing and saving a document file (*.mxd).

 
 
 public void SaveAs (string sDocument,bool bUseRelativePaths,bool bCreateThumnbail);

IMxdContents接口:Provides access to members to pass data into and out off a MXD map document file. Coclasses that implement this interface can limited the implementation to one property if required.

1 Create a new blank Mxd document:

          string path=@"f:\TEST\untitled.mxd";

            MapDocument pMapDocument = new MapDocumentClass();

            pMapDocument.New(path);

            pMapDocument.Open(path, "");

            axMapControl1.Map = pMapDocument.get_Map(0);

2 Open an Mxd document to modify, edit and save in the original file:

           IMxdContents pMxdC;

            pMxdC = axMapControl1.Map as IMxdContents;

            IMapDocument pMapDocument = new MapDocumentClass();

            pMapDocument.Open(axMapControl1.DocumentFilename, "");

            IActiveView pActiveView = axMapControl1.Map as IActiveView;

            pMapDocument.ReplaceContents(pMxdC);

            pMapDocument.Save(true, true);

3 Custom load various data, that is, there is no Mxd file at the beginning, then modify and edit, save the current map as an Mxd file

          SaveFileDialog Sfd = new SaveFileDialog();

            Sfd.Title = "Save Document As";

            Sfd.Filter = "(*.mxd)|*.mxd";

            Sfd.ShowDialog ();

            string path = Sfd.FileName;

            IMxdContents pMxdC;

            pMxdC = axMapControl1.Map as IMxdContents;

            IMapDocument pMapDocument = new MapDocumentClass();

            pMapDocument.New(path);

            IActiveView pActiveView = axMapControl1.Map as IActiveView;

            pMapDocument.ReplaceContents(pMxdC);

            pMapDocument.Save(true, true);

https://www.cnblogs.com/janeaiai/p/4991784.html

Guess you like

Origin blog.csdn.net/soderayer/article/details/114838546