阅读:1522回复:0
C#中创建FeatureClass问题
<P> 代码如下,在CreateFeatureClass的时候总是弹出异常</P>
<P> PropertySet ps = new PropertySet();<BR> ps.SetProperty("SERVER", "douw");<BR> ps.SetProperty("INSTANCE", "5151");<BR> ps.SetProperty("User", "sde");<BR> ps.SetProperty("PASSWORD", "sde");<BR> ps.SetProperty("VERSION", "SDE.DEFAULT");<BR> pSdeFact = new SdeWorkspaceFactory();<BR> pwks = pSdeFact.Open(ps, 0);</P> <P> if (pwks != null)<BR> MessageBox.Show("success");<BR> if (pwks == null)<BR> return;<BR> IFeatureWorkspace pfwks = pwks as IFeatureWorkspace;<BR> string name = "drawing1";<BR> IFields fds = new ESRI.ArcGIS.Geodatabase.FieldsClass();<BR> IField fd = new ESRI.ArcGIS.Geodatabase.FieldClass();<BR> IFieldEdit fde = fd as IFieldEdit;<BR> fde.Name_2 = "SHAPE";<BR> fde.Type_2 = esriFieldType.esriFieldTypeGeometry;<BR> IGeometryDef pGeomDef = new GeometryDefClass();<BR> IGeometryDefEdit pGeomDefEdit = pGeomDef as IGeometryDefEdit;<BR> pGeomDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;<BR> pGeomDefEdit.SpatialReference_2 = new UnknownCoordinateSystemClass();<BR> fde.GeometryDef_2 = pGeomDef;<BR> IFieldsEdit fdse = fds as IFieldsEdit;<BR> fdse.FieldCount_2 = 1;<BR> fdse.set_Field(0, fd);<BR> IFeatureClass pfc;<BR> pfc=pfwks.CreateFeatureClass(name, fds, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");</P> |
|