Solved! Go to Solution.
import arcpy arcpy.env.workspace = r"[Path to an SDE connection file goes here]" featureClasses = arcpy.ListFeatureClasses("G*", "ALL") for featureClass in featureClasses: print featureClass
IWorkspaceFactory workspaceFactory = new WorkspaceFactory(); IWorkspace workspace = workspaceFactory.OpenFromFile("[Path to an SDE connection file goes here]", 0); var namesEnum = workspace.DatasetNames[esriDatasetType.esriDTFeatureClass]; var tempName = namesEnum.Next(); while (tempName != null) { // Add string comparison logic here, e.g. tempName.Name.StartsWith("G") Console.WriteLine(tempName.Name) tempName = namesEnum.Next(); }
Here are a couple options.
C# / ArcObjects:IWorkspaceFactory workspaceFactory = new WorkspaceFactory(); IWorkspace workspace = workspaceFactory.OpenFromFile("[Path to an SDE connection file goes here]", 0); var namesEnum = workspace.DatasetNames[esriDatasetType.esriDTFeatureClass]; var tempName = namesEnum.Next(); while (tempName != null) { // Add string comparison logic here, e.g. tempName.Name.StartsWith("G") Console.WriteLine(tempName.Name) tempName = namesEnum.Next(); }
var namesEnum = workspace.DatasetNames[esriDatasetType.esriDTFeatureClass]; var tempName = namesEnum.Next(); // get value null
From SDK help:
Note that only the top-level datasets in the workspace are returned by these methods. In particular, if a workspace contains both stand-alone feature classes and additional feature classes that are part of a feature dataset, then calling the DatasetNames property on the workspace with a dataset type of esriDTFeatureClass will return only the standalone feature classes. In order to get the feature class names within a feature dataset, the application needs to get the FeatureClassNames property on the top-level feature dataset name returned by the workspace.
IWorkspace.DatasetNames Property will list all matched types for the top level only.
If your feature classes are inside featuredataset you should use IFeatureDatasetName.FeatureClassNames After you get your dataset.