Can you please let me know how I can list all layers inside a saved .mxd map and also get list of layers inside a SDE database connection using c# and ArcObjects? For example if I have a map document like "C:/GIS/Project.mxd"
and a sde connection
to enterprise geodatabase like "projects.sde"
under database connection node, h lo w can I get access to them and list their contents?
I know how to do this using Python - ArcPy scripting like
import arcpy mxd = arcpy.mapping.MapDocument(r"C:\GIS\Project.mxd") df = arcpy.mapping.ListDataFrames(mxd, "")[0] for lyr in arcpy.mapping.ListLayers(mxd, "", df): print lyr.name
But couldn't find a solution for ArcObject!
I'm not sure about the SDE but for the MXD look at the IMapDocument interface and MapDocument class. You can use them to open an existing MXD. Each MapDocument can contain one or more maps which you can iterate through. For each map you can iterate through the layers inside of them.