I’m trying to rename an attribute table field (see code snippet below, Sf is a shapefile object).
'Renames a field in the shapefile's attribute table
Dim FldIdx As Integer
If Sf Is Nothing Then Return False
FldIdx = Sf.FieldIndexByName(CurrentFldName)
If FldIdx < 0 Then Return False
Sf.StartEditingTable()
Dim Fld As MapWinGIS.Field = Sf.Table.Field(FldIdx)
Fld.Name = NewFldName
' check the change
FldIdx = Sf.FieldIndexByName(NewFldName)
Sf.StopEditingTable()
Dim Ok As Boolean = Sf.SaveAs(FullFileName)
ErrMsg2 = Sf.ErrorMsg(Sf.LastErrorCode)
All goes well, but it will not save the shapefile (no errors though).
I can’t find anything wrong with the shapefile.
As a workaround I could add a new field, copy the contents of the old one and delete the old field, but I’m trying to keep it simple.
Any suggestions would be welcome?
Cheers
Francis