I am using the following code:
var images = from pic in slidePart.Slide.Descendants<DocumentFormat.OpenXml.Presentation.Picture>()
select pic;
foreach (var image in images)
image.Remove();
The problem is with the loop which executing only once and images contain multiple objects. How can I call image.Remove on all objects.
Try this:
Why the
.ToList()call? Because you need to ensure that you don’t modify the collection you are iterating over.