创建featureclass,为它赋别名,并移动到数据集下

 1 if (pOutFtrClass == null)
 2                     {
 3                         //continue;
 4 //创建featureclass
 5                         //得到规范的字段集
 6                         IFields pFields = pFeatureClass.Fields;
 7                         //在目标工作空间中创建要素类
 8                         IFieldChecker fieldChecker = new FieldCheckerClass();
 9                         IEnumFieldError enumFieldError = null;
10                         IFields validatedFields = null;
11                         fieldChecker.ValidateWorkspace = pDataset.Workspace;
12                         fieldChecker.Validate(pFields, out enumFieldError, out validatedFields);                        
13 pOutFtrClass = (pDataset.Workspace as IFeatureWorkspace).CreateFeatureClass((pFeatureClass as IDataset).Name, validatedFields, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");
14 //为此featureclass赋别名
15                         IClassSchemaEdit classedit = pOutFtrClass as IClassSchemaEdit;
16                         string aliasName = pFeatureClass.AliasName;
17                         if (!string.IsNullOrEmpty(aliasName))
18                         {
19                                //如果是表格要加上这句,添加一个oid
                    //classedit.RegisterAsObjectClass("OBJECTID", null);
                    classedit.AlterAliasName(aliasName);
20 } 21 //把此featureclass移动到目标数据集下 22 (pDataset as IDatasetContainer).AddDataset(pOutFtrClass as IDataset); 23 24 }

另,若要在

在sde的工作空间中.CreateFeatureClass需用 esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB许可

posted @ 2014-03-04 16:39  寻梦放歌  阅读(966)  评论(0编辑  收藏  举报