Geodatabase - 打开要素类

 1 string dbPath = @"G:\doc\gis\1.400\data\pdb.mdb";

 2 ESRI.ArcGIS.Geodatabase.IWorkspaceFactory wsf = new ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactoryClass();

 3 ESRI.ArcGIS.Geodatabase.IWorkspace ws = wsf.OpenFromFile(dbPath, 0);

 4 ESRI.ArcGIS.Geodatabase.IEnumDataset eds = ws.get_Datasets(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTAny);

 5 ESRI.ArcGIS.Geodatabase.IDataset ds = null;

 6 while ((ds = eds.Next()) != null) {

 7     //要素类.

 8     if (ds.Type == ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTFeatureClass)

 9         MessageBox.Show(ds.Name);

10     //要素数据集.

11     else if (ds.Type == ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTFeatureDataset) {

12         ESRI.ArcGIS.Geodatabase.IEnumDataset subEDS = ds.Subsets;

13         ESRI.ArcGIS.Geodatabase.IDataset sds;

14         while ((sds = subEDS.Next()) != null) {

15         MessageBox.Show("sub:" + sds.Name);

16         }

17     }

18     else {

19 

20     }

21 }

 

你可能感兴趣的:(database)