Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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.

share|improve this answer
    
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 Nov 1 '11 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 Nov 1 '11 at 16:06
    
Thank you, that is much more clear. –  Nathanus Nov 1 '11 at 16:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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