Copying slides and notes from numerous ppts into a new one

hi i have this code

protected void Page_Load(object sender, EventArgs e)

{

Session["style"] = "design1.ppt";

try

{

string[] selectedPPTs = Session["selectedSlides"] as string[];

string sqlIn = "";

if (0 != selectedPPTs.Length)

{

for (int x = 0; x < selectedPPTs.Length; x++)

{

sqlIn += selectedPPTs[x] + ",";

Response.Write("file id = " + selectedPPTs[x] + "
");

}

sqlIn = sqlIn.Substring(0, sqlIn.Length - 1);

try

{

//con = new SqlConnection(ConfigurationSettings.AppSettings["asposeslideDbConn"]);

con = new SqlConnection("Data Source=localhost;Initial Catalog=asposeslidetest;Persist Security Info=True;User ID=ish;ll=lll");

cmd = new SqlCommand("sp_get_selected_slides", con);

cmd.CommandType = CommandType.StoredProcedure;

SqlParameter objParam1;

objParam1 = cmd.Parameters.Add("@inclaus", SqlDbType.NVarChar);

objParam1.Direction = ParameterDirection.Input;

objParam1.Value = sqlIn;

if (con.State.Equals(ConnectionState.Closed))

{

con.Open();

SqlDataReader srdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

if (null != Session["style"])

{

}

while (srdr.Read())

{

Presentation dstPres = new Presentation(@Server.MapPath("") + "\\creationtest.ppt");

CloneSlideWithNotes(srdr[2].ToString(), Convert.ToInt32(srdr[1]), dstPres);

dstPres.Write(@Server.MapPath("") + "\\creationtest.ppt");

}

}

}

catch (Exception dbQueryEx)

{

Response.Write("problem with query on line 74 " + dbQueryEx.Message + "sql in = " + sqlIn);

}

}

}

catch (Exception pgLoadEx)

{

Response.Write("prolem exception fired on line 80"+ pgLoadEx.Message);

}

}

protected void CloneSlideWithNotes(string srcPres, int srcSlidePosition, Presentation dstPres)

{

try

{

Response.Write("line 89 all ok
");

Presentation clonePres = new Presentation(@Server.MapPath("") + "\\uploaded_ppts\\" + srcPres);

Slide srcSld;

srcSld = clonePres.GetSlideByPosition(srcSlidePosition);

if (srcSld == null)

return;

int dstSldPosition;

dstSldPosition = dstPres.Slides.LastSlidePosition + 1;

Slide dstSld = dstPres.AddEmptySlide();

clonePres.CloneSlide(srcSld, dstPres.Slides.LastSlidePosition + 1, dstPres, new SortedList());

dstSld.AddNotes();

dstSld.Notes.Paragraphs.Clear();

//add all the pargraphs in notes of sldSrc into the notes of dstSld

foreach (Paragraph srcPara in srcSld.Notes.Paragraphs)

{

Response.Write("line 109
");

//Create the replica of srcPara

Paragraph dstPara = new Paragraph(srcPara);

//Add this Replica to dstSld.Notes.Paragraphs

dstSld.Notes.Paragraphs.Add(dstPara);

}

}

catch (Exception CloneSlideEx)

{

Response.Write("error in cloneslide method " + CloneSlideEx.Message);

}

}

it seems to work fine until i add different ppts then it throws the error

The process cannot access the file 'C:\Inetpub\wwwroot\apose2\creationtest.ppt' because it is being used by another process

any clues

Please see my response in this thread.

<A href="</A></P>