Select to view content in your preferred language

Programmatically Identifying Broken Data Links

495
1
02-17-2012 05:16 AM
GeorgeFaraj
Frequent Contributor
In Engine code how can identify the broken data links? When I use the following code I can read the links in a document. If the document has broken links then this code just blows up with a FAIL COM error. I would like to be able to allow the user to repair broken links from Engine code (in other words I am not interested in script solutions.)  Is this even possible in Engine code?  Has anyone ever done this? Does anyone have code that attempts to do this?

            Dictionary<string, string> datasetList_ = new Dictionary<string,string>();
            IDataset dataset = layer as IDataset;
            if ( dataset == null ) return datasetList_;
                IEnumDatasetName enumDatasetName = dataset.Workspace.get_DatasetNames( esriDatasetType.esriDTAny );
                IDatasetName datasetName;
                while ( ( datasetName = enumDatasetName.Next() ) != null ) {

                    datasetList_.Add( datasetName.Name, datasetName.WorkspaceName.PathName );
                }
            }
            return datasetList_;
0 Kudos
1 Reply
NeilClemmons
Honored Contributor
If a layer has a broken data link then ILayer::Valid returns False.
0 Kudos