如何删除要素类
要想删除一个要素类,那么必须先得到这个,在得到这个要素类的时候,我们要学习一个新的接口IFeatureWorkspace。
IFeatureWorkspace 接口介绍
这个接口主要是用于管理基于矢量数据的,如表,,要素类,要素数据集等。
Members
Description | ||
---|---|---|
CreateFeatureClass | Creates a new standalone feature class under the workspace. | |
CreateFeatureDataset | Creates a new feature dataset. | |
CreateQueryDef | Create a query definition object. | |
CreateRelationshipClass | Creates a new relationship class. | |
CreateTable | Creates a new table. | |
OpenFeatureClass | Opens an existing feature class. | |
OpenFeatureDataset | Opens an existing feature dataset. | |
OpenFeatureQuery | Opens a feature dataset containing a single feature class defined by the specified Query. | |
OpenRelationshipClass | Opens an existing relationship class. | |
OpenRelationshipQuery | The table of a relationship join query. | |
OpenTable | Opens an existing table. |
Classes | Description |
---|---|
Sde3Workspace (esriDataSourcesGDB) | ESRI SDE (3.x) Feature Database. |
Sde4Workspace (esriDataSourcesGDB) | ESRI SDE (4.x) Feature Database. |
VersionedWorkspace | VersionedWorkspace Object. |
Workspace | Workspace Object. |
OpenDataset,OpenTable,OpenFeatureClass都是要传入一个相应的名称,如要打开一个名称为PointTest的要素类,只需要在OpenFeatureClass中传入这个要素类的名称,代码如下:
IWorkspaceFactory pWsFt = new AccessWorkspaceFactoryClass();
IWorkspace pWs = pWsFt.OpenFromFile(WsName, 0);
IFeatureWorkspace pFWs = pWs as IFeatureWorkspace;
IFeatureClass pFClass = pFWs.OpenFeatureClass("PointTest");
如果是在ArcMap中,我们会切换到Catalog中然后进入相应的数据库,然后删除相应的要素类,这种操作会让我们想到FeatureClas这个对象会提供删除的方法,其实不然,这个删除的方法是定义在Dataset这
个对象中。
private void button1_Click(object sender, EventArgs e)
{
string WsName = WsPath();
if( WsName !="")
{
IWorkspaceFactory pWsFt = new AccessWorkspaceFactoryClass();
IWorkspace pWs = pWsFt.OpenFromFile(WsName, 0);
IFeatureWorkspace pFWs = pWs as IFeatureWorkspace;
IFeatureClass pFClass = pFWs.OpenFeatureClass("PointTest");
IDataset pDatset = pFClass as IDataset;
pDatset.Delete();
}
}