When you save an ArcGIS map document (MXD) and then change the data source of a layer in the MXD, you can no longer see the layer in the MXD and you must redefine its data source.
But suppose you need to discover the previous data source's feature class name. In ArcMap, you can find it under the layer's Properties -> Source Tab, but I want to access this information programmatically.
I tried the code below but it doesn't work for this kind of layer. Can anyone suggest another method for retrieving the properties of a layer whose data source has been lost?
ctype(mLayer,IFeatureLayer).aliasname
-
1This will fail as the source doesn't exist. Try using a property dialog...and retrieve the value from there. Refer this link and this forum linkujjwalesri– ujjwalesri2011年07月20日 07:54:11 +00:00Commented Jul 20, 2011 at 7:54
2 Answers 2
If the layer implements the IDataLayer interface (most layers do), you can access its IDataLayer.DataSourceName property.
For example, for a feature layer, this property will return the FeatureClassName object, which provides various interfaces to examine the data source.
This will fail as the source doesn't exist.
Try using a property dialog...and retrieve the value from there. Refer this link and this forum link