Thank you very much. Using Rebuild like this should get me what I'm after. I have a couple questions however based on what I'm seeing Rebuild do.
First off, if I replace the call to
ShapeFileFeatureSource.Rebuild(testdata, ShapeFileSortingMode.Default, 4326);in your sample code with this one
ShapeFileFeatureSource.Rebuild(testdata);It doesn't appear to do anything. The deleted record still exists within the .DBF file. Why is this means of calling Rebuild no longer doing anything? I'm not seeing any compiler warnings about it being depricated nor any errors from using it, it just doesn't seem to be doing anything anymore.
Second question, if I replace the call to
ShapeFileFeatureSource.Rebuild(testdata, ShapeFileSortingMode.Default, 4326);
ShapeFileFeatureSource.Rebuild(testdata, ShapeFileSortingMode.None, 4326);the ordering of the records in the resulting Shapefile isn't quite what I would expect. ShapeFileSortingMode.Default appears to leave the order alone in this example and therefore the records which started as 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 after deleting 5 and doing the Rebuild with ShapeFileSortingMode.Default I end up with the records in order 1, 2, 3, 4, 6, 7, 8, 9, 10. Doing the same but specifying ShapeFileSortingMode.None I end up with records in order 1, 10, 2, 3, 4, 6, 7, 8, 9; that seems rather strange as by specifying None I would expect that to mean not to reorder them, but maybe "None" means something more akin to "Do whatever you want" and "Default" means leave the order unchanged. So I used "Default" in my own app, added two records to my Shapefile, which would have added them to the end, then deleted the second to last one I had added and checked the results after having called Rebuild. To my surprise my recently added record was now about in the middle of my Shapefile (record number 25 out of 46). So it appears neither "None" nor "Default" actually mean leave the order of records in the DBF file unchanged. So, I guess my two part question is what do "ShapeFileSortingMode.None" and "ShapeFileSortingMode.Default" actually mean and is there an option that can be specified to tell it to leave the order within the .DBF file unchanged (but still compact the Shapefile)?
Thanks for any insight you can provide.