Get all layer names

6692
16
Jump to solution
10-21-2015 12:19 AM
MuneemHabiba
New Contributor

I have been trying for more then 4 hours but i am cinfused how i should get all layer names from gdb files. I am using latest file goedatabase API but there is no help that i can found to get all layernames in gdb. Then i have to read further each layer items.

Any help will be highly appreciated. I am attaching my gdb file

Tags (2)
0 Kudos
16 Replies
VinceAngelo
Esri Esteemed Contributor

The file geodatabase data model only has two levels:

  1. simple tables or containers
  2. tables within containers

You cannot place a feature dataset (or any other container) within a feature dataset (or any other container).  This is why I test with OpenTable (which has the side effect of letting you access the field information).

- V

0 Kudos
MuneemHabiba
New Contributor

sir now we have feature classes. now how to read metadata(RGN and DES file) of each of feature classes?

0 Kudos
VinceAngelo
Esri Esteemed Contributor

I'm sorry, but I have no idea what an RGN or DES file might be.

The only place metadata is stored "in" a feature class is in the XML document which defines the feature class, which is exposed by Geodatabase::GetDatasetDocumentation().  Once you have the XML you can parse it with whatever tool you like.

In the future, please start a new thread to ask a new question.

- V

0 Kudos
WardSegers
New Contributor

Hello Vince,

I had the same question as muneem: How to find the top level contents in a FGDB.  I just had a look at your sample code, but I fail to understand it.  I am working in C#.  According to the C# documentation that came with the API the "GetChildDatasets" method takes only two parameters, yet in your example you supply this function with 3 parameters.

Is there a difference between the C++ and the C# API here?  What would be the C# alternative to get the top level content?

Thanks in advance!

Ward Segers.

0 Kudos
VinceAngelo
Esri Esteemed Contributor

C# is a wrapper around C++. All functions return status in C++, but that is covered by exceptions in C#, so the third parameter of GetChildDatasets in C++ (which is the returned object pointer, by reference) is just the returned value in C#. If you pull up the documentation for both C++ and C# side by side, the equivalents should be intuitive.

In C#, the top level would be extracted exactly the same, using Geodatabase.GetChildDatasets with a parentPath of "\" and a dataSetType of ""("Feature Class" for only feature classes).

- V

WardSegers
New Contributor

Hey Vince,

Now that you explained it all makes perfect sense :-).

Just wanted to point out that in C# the parent path should be expressed as "\\" instead of "\"

Thanks!

Ward Segers.

0 Kudos
VinceAngelo
Esri Esteemed Contributor

Yes, in languages where backslashes are escaped (C/C++/Java/C#/Python*), the string "\" will be represented "\\".  As noted in my answer, the command-line is not one of those places, so if the parameter is being passed from the command-line, the string "\" must be used ("\\" attempts to find the empty-string named child of the empty-string dataset [which can't exist, so no rows are returned]).

- V

* Except when a literal flag is used on the string, e.g., "path = r'\' "

0 Kudos