2

I want to do a "Extending ArcObjects: Windows Application" app:

enter image description here

I have a code snippet that lists all the layers from the MXD files stored in a directory:

string[] fileEntries = Directory.GetFiles("C://path");
foreach (string fileName in fileEntries) {
            IMapDocument mapDoc = new MapDocument();
            mapDoc.Open(fileName);
            IMap map = mapDoc.Map[0];
            for (int i = 0; i < map.LayerCount; i++)
            {
                ILayer l = map.Layer[i];
            }

That part is working perfectly.

Now I need to list all the tables, but I don't know how to create the IMxDocument object I need for that. It looks like that with that method I can only get the Tables from the current document in an Add-In.

How can I get the Tables of the MXD files stored in a directory using ArcObjects?

I already know how to do this with ArcPy, but I really need to be able to do the same with ArcObjects.

3
  • 2
    Did you try casting map to IStandaloneTableCollection, then iterating ? Jun 27, 2018 at 18:50
  • Thanks! Your comment took me in the right path. I get the ActiveView from the IMapDocument object. Then I perform a FocusMapin the ActiveView to get the IMap object. I cast the last one to IStandaloneTableCollection as you have told me and now I can get the list of tables.
    – O.D.
    Jun 28, 2018 at 6:23
  • 2
    Keep in mind an mxd can contain multiple maps. I would iterate ... for(int i=0;i<mapDoc.MapCount;i++) map = mapDoc.Map[i] instead. Jun 28, 2018 at 13:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.