Up to now code is read the template and replace with new values and finally replace the docx file with new values. Can any one please tell me how to save the replaced docx file in diffrent name?.
My code is bellow.
using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(document, true))
{
string docText = null;
using (StreamReader sr = new StreamReader(wordDoc.MainDocumentPart.GetStream()))
{
docText = sr.ReadToEnd();
}
Regex regexText = new Regex("#ApplicationCompleteDate#");
docText = regexText.Replace(docText,DataHolding.ApplicationCompleteDate);
regexText = new Regex("#ApplicantPrivateAddress#");
docText = regexText.Replace (docText,UserDataHolding.ApplicantPrivateAddress);
using (StreamWriter sw = new StreamWriter(wordDoc.MainDocumentPart.GetStream (FileMode.Create)))
{
sw.Write(docText);
}
}
If any one help me with this creating new docx file by changing above code, it will be very helpful for me.
thank You.