转自原文 ArcSDE:C#创建SDE要素数据集
- /// <summary>
- /// 判断指定数据集是否存在
- /// </summary>
- /// <param name="workspace">工作空间名称</param>
- /// <param name="strDataSetName">数据集名称</param>
- /// <returns>存在,true;否则,false</returns>
- public static bool isDatasetExist(IWorkspace workspace, string strDataSetName)
- {
- if (workspace == null)
- {
- return false;
- }
- else if (workspace.get_NameExists(esriDatasetType.esriDTFeatureDataset, strDataSetName))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 创建要素数据集
- /// </summary>
- /// <param name="workspace">工作空间名称</param>
- /// <param name="strDatasetName">数据集名称</param>
- /// <param name="spatialReference">参考系</param>
- public static void CreateFeatureDataset(IWorkspace workspace,string strDatasetName, ISpatialReference spatialReference)
- {
- IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace;
- if (featureWorkspace == null)
- return;
- if (!isDatasetExist(strDatasetName))
- {
- featureWorkspace.CreateFeatureDataset(strDatasetName, spatialReference);
- }
- }