public static bool writeWord(ArrayList alItemName, ArrayList alItemText, string strDemoFile, string strTempFile) { bool flag = false; try { KillProcess("WINWORD"); File.Copy(strDemoFile, strTempFile, true); CCWordApp cw = new CCWordApp(); //System.Threading.Thread.Sleep(1000 * 5 ); if (File.Exists(strTempFile)) { cw.Open(strTempFile); for (int i = 0; i < alItemName.Count && i < alItemText.Count; i++) { cw.ReplaceText(alItemName[i].ToString(), alItemText[i].ToString()); } //for (int i = 0; i < alPicName.Count && i < alPicFilePath.Count; i++) //{ // cw.ReplacePic(alPicName[i].ToString(), alPicFilePath[i].ToString(), alPicWidth[i], alPicHeight[i]); //} cw.Save(); cw.Quit(); cw = null; if (File.Exists(strDemoFile)) { flag = true; } } } catch (Exception e) { Console.WriteLine(e.ToString()); flag = false; } KillProcess("WINWORD"); System.GC.Collect(); return(flag); }