AnsweredAssumed Answered

How to get the full path of a layer

Question asked by sfarley on Nov 12, 2019
Latest reply on Dec 23, 2019 by Hornbydd

I am trying to programmatically create a full copy of a layer on my map in ArcMap so that the user can run tools to clean up the data without mucking with the original in case they do something wrong. I have it working in ArcPro, but, because of speed issues, I am now trying to implement my cleanup tools in ArcMap. In ArcPro, my code looks like


var lyr = _arcFac.MainMapView.Map.GetLayersAsFlattenedList()

await QuededTask.Run(() =>


   foreach (BasicFeatureLayer fmLyr in lyr) {

         var hydLayer = fmLyr as FeatureLayer;

         var hydClass = hydLayer .GetFeatureClass();

         var hydStore = hydClass.GetDatastore();

         var hydPath = Path.Combine(hydStore.GetPath().LocalPath, hydClass.GetName());


         string newFileName = $"MergeLayer.shp";

         var mva = Geoprocessing.MakeValueArray(hydPath + ".shp", $@"{hydPath}" newFileName);

         var res2 = Geoprocessing.ExecuteToolAync("copy_Management", mva);




In ArcMap, I have 

         IFeatureLayer hydLayer = selectedLayer[0];

         var hydClass = hydLayer .FeatureClass();

         var hydStore = hydClass.FeatureDataset(); //this is null


So, how do I get the full path of the selected layers? File.GetPath(selectedLayer[0]) get the correct path only if it is in the same path as the map and if you have saved the map. 


Thank you,