Retrieve data source from layer within MXD

Discussion created by ecobio on Dec 14, 2010
Latest reply on Jan 1, 2011 by VPrasad-esristaff
Hi all:

I'm having difficulty trying to programatically access the data source for layers within an mxd.  Code follows:

DirectoryInfo di = new DirectoryInfo(folder);
            FileInfo[] files = di.GetFiles("*.mxd");
            Dictionary<string, List<String>> referencedFiles = new Dictionary<string,List<string>>();

            foreach (FileInfo fi in files)
                referencedFiles.Add(fi.FullName, new List<string>());

                IMapDocument doc = new MapDocument();
                doc.SetActiveView(doc.PageLayout as IActiveView);

                IEnumLayer pEnumLayer = doc.ActiveView.FocusMap.Layers;
                ILayer pLayer;
                while ((pLayer = pEnumLayer.Next()) != null)
                    IFeatureLayer pFL = pLayer as FeatureLayer; 
                    IFeatureClass pFC = pFL as IFeatureClass; // pFC is coming up null every time for all shapefile layers.