Deleting shapes from shapefile

Aug 4, 2011 at 4:28 PM

Greeting, I'm working on a dot net project


I want to delete all shapes on a shapefile (in memory)


but for some reason it was working int he past but not anymore.

There is what we were been using in the past

shp.EditClear(); was working in the past but for some reason it return false now


I also tried this version and it does an infinite loop

 bool result = shp.StartEditingShapes(true, null);           

while (shp.NumShapes > 0)    {            

   shp.EditDeleteShape(shp.NumShapes - 1);   




anyone has any hint about this problem?

Thank you

Aug 8, 2011 at 12:46 AM

I can't confirm this. Message box return 0 for both EditClear and EditDeleteShape.

        private void button9_Click(object sender, EventArgs e)
            MapWinGIS.Shapefile sf = new Shapefile();
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = sf.CdlgFilter;
            if (dlg.ShowDialog() == DialogResult.OK)
                if (sf.Open(dlg.FileName, null))
                    MessageBox.Show("Number of shapes: " + sf.NumShapes.ToString());
                    if (sf.StartEditingShapes(true, null))

                        for (int i = sf.NumShapes - 1; i >= 0; i--)
                        MessageBox.Show("Number of shapes: " + sf.NumShapes.ToString());