Free Support Forum - aspose.com

Adding Pictures Leaves Files Locked

Hi,

I am evaluating Aspose.PowerPoint and am trying adding some pictures to a presentation. I have created a template with one picture frame with a dummy picture. During execution I am dynamically creating picture files (e.g. “temp1.jpg”, “temp2.jpg”, etc.), cloning the slide and replacing the picture in each slide with one of the new images I have created.

This works, however it seems to leave the image files locked, even after I have closed the presentation. This means that if I try to delete the files or run the program again, it fails, as the old temporary files still exist and are locked.

This is an extract of my code (c#):

for (i = 0; i < numSlides; i++)

{
tempChartFile = tempChartBase + “-” + Convert.ToString(i) + “.jpg”;

// Save chart image to new temporary file

Steema.TeeChart.Export.JPEGFormat.SaveToFile(ch1, tempChartFile);

// Insert picture

pictureID = pres.Pictures.Add(new Picture(pres, tempChartFile));

shapes = slides[i+1].Shapes;

for (int j=0; j<shapes.Count; j++)

{

PictureFrame pf = shapes[j] as PictureFrame;

if (pf != null)

{

pf.PictureId = pictureID;

}

}

}

this.Response.ContentType = “application/vnd.ms-powerpoint”;

this.Response.AppendHeader(“Content-Disposition”, “attachment; filename=demoppt.ppt”);

this.Response.Flush();

System.IO.Stream st = this.Response.OutputStream;

//

// Write the file

//

pres.Write(st);

this.Response.End();


Does anyone know why this is and how to correct it?

Thanks

Dave.