Free Support Forum - aspose.com

Cannot remove first section in presentation

I have a process where I open a presentation and remove some slides, insert some slides from other presentations and re-organize them within sections. One issue I am running into is that I cannot remove the first section. I can remove all the other sections, but if I try and remove the first one, it gives the following error:
09:55:58,784 INFO [stdout] (default task-5) com.aspose.slides.exceptions.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
09:55:58,784 INFO [stdout] (default task-5) Parameter name: Parameter name: index
09:55:58,784 INFO [stdout] (default task-5) at com.aspose.slides.Collections.Generic.List.get_Item(Unknown Source)
09:55:58,784 INFO [stdout] (default task-5) at com.aspose.slides.SectionCollection.removeSection(Unknown Source)

I can rename the section, which I do if I have new sections to insert, but if I want to get rid of all existing sections I cannot do it. The following simple code will generate this issue:

newPres.getSections().removeSection(newPres.getSections().get_Item(0));

@mike.geier

Please share the working sample code along with source presentation file reproducing the issue. Please also try using latest Aspose.Slides 20.9 on your end before this as well.