I'm currently writing an arcobjects app that performs an arbitrary set of geoprocessing tasks on a group of shapefiles and/or dbf tables. My current implementation uses Directory.GetFiles to build an array of file paths which I feed to various GP execution functions. I'm wondering if ListDatasets can perform the same task. I need to search an entire directory tree starting at a given root folder for all files which match a given search string. I am not certain if ListDatasets will do this (I have a devil of a time deciphering the SDK documentation).

In short, which would prove more efficient and effective and recursively searching a directory tree for .shp and .dbf files, Directory.GetFiles, GP.ListDatasets, or some heretofore unmentioned method?

1 Answer 1


I would imagine using the built-in C# methods would be faster for using recursively, but of course you could only do it with files, not geodatabase feature classes/tables. Here's an example of a recursive file/directory processor: Directory.GetDirectories

If going the ArcObjects route I would look at the help topic "How to list data", which has all the keywords expected. Looks like you would want to use a combination of ListTables and ListFeatureClasses, and ListWorkspaces to recurse folder workspaces. Use ListDatasets if you are in a geodatabase and need to look in Feature Datasets.

If speed is not critical I would probably use the ArcObjects methods especially if there was a chance I would ever want to use geodatabases. I think they also check that each file they come upon is valid, i.e. they won't list shapefiles that are missing a critical file, or a file that happens to have a .shp extension but isn't actually a shapefile.

You could always do both and time it yourself.

  • I think another concern I'm having is that ListDatasets will not return tables as well as shapefiles. I am not sure that I understand the method properly, though. Will ListDatasets return shp and dbf, or is it only for finding workspaces like gdbs?
    – Nathanus
    Commented Nov 1, 2011 at 15:05
  • Added some more info to the answer, hopefully that helps. ListDatasets only returns Feature Datasets and a few other dataset types like TINs.
    – blah238
    Commented Nov 1, 2011 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.