AnsweredAssumed Answered

Get list of layers/Tables from a File Geodatabase

Question asked by vsambandhan on Jun 1, 2016
Latest reply on Jun 1, 2016 by vsambandhan

I am trying to use a GP tool to export a Layer to a File GDB. Is there a way to find which layers are already present in the GDB so that I can give a different name to my Layer. The code below works but was hoping there is a better way to do this.

thank you,

Vijay

            string featureClassName = AppConstants.ExportProposedBuildingName;

            IReadOnlyList<string> valueArray = null;

            await QueuedTask.Run(() =>

            {

                Geodatabase fileGeodatabase = new Geodatabase(@"c:\0_Projects\CapeCodCommission\CapeCod.gdb");

                bool isFound = true;

                int index = 0;

                while (isFound)

                {

                    try

                    {

                        fileGeodatabase.OpenDataset<Table>(featureClassName);

                        isFound = true;

                        featureClassName = AppConstants.ExportProposedBuildingName + "_" + ++index;

                    }

                    catch

                    {

                        isFound = false;

                    }

                }

                valueArray = Geoprocessing.MakeValueArray

                    (proposedBuildingLayer, @"C:\0_Projects\CapeCodCommission\CapeCod.gdb\" + featureClassName);

            });

Outcomes