I’m using the following snipit to build a shape file with a set of column data from an InMemoryFeatureLayer. This worked well in version 7, but I am now finding that it is garbling the output columns in version 8.0.0.52 which I upgraded to a couple weeks ago. The garbled DbfColumns makes the shapefile unreadable in all systems I have tested. If I switch back to version 7, the code works fine.
I also notice that the TypeName property of the FeatureSourceColumn is always null which means I am forced to set the DbfColumnType to string as opposed to setting it automatically.
// Get the columnsCollection<DbfColumn> allColumns = new Collection<DbfColumn>();
fl.Open();foreach (FeatureSourceColumn column in fl.FeatureSource.GetColumns()){
if (column.ColumnName == “Shape” || column.ColumnName == “SHAPE”) continue;
DbfColumnType colType = new DbfColumnType();
// Not sure what TypeName is as it’s always Null???switch (column.TypeName){
default:colType = DbfColumnType.String;break;}
// Need to make the column maximum a high number as we don’t know what it could beallColumns.Add(new DbfColumn(column.ColumnName, colType, 500, 0));
}
ShapeFileType shapeFileType = ShapeFileType.Polygon;
ShapeFileFeatureLayer.CreateShapeFile(shapeFileType,shapeName, allColumns, Encoding.ASCII, OverwriteMode.Overwrite);
ShapeFileFeatureLayer shapeFileLayer = new ShapeFileFeatureLayer(shapeName, ShapeFileReadWriteMode.ReadWrite);
fl.Open();foreach (Feature feature in fl.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns)){shapeFileLayer.Open();try{Feature convertedFeature = proj4.ConvertToInternalProjection(feature);
shapeFileLayer.EditTools.BeginTransaction();shapeFileLayer.EditTools.Add(convertedFeature);TransactionResult result = shapeFileLayer.EditTools.CommitTransaction();}finally{shapeFileLayer.Close();}}fl.Close();