public void UpdateTOC(string file1, string file2)
{
using (var mainDoc = WordprocessingDocument.Open(file1, false))
using (var resultDoc = WordprocessingDocument.Create(file2, WordprocessingDocumentType.Document))
{
foreach (var part in mainDoc.Parts) resultDoc.AddPart(part.OpenXmlPart, part.RelationshipId);
}
}
This is the code I am using.. File1 is the base document which will be in the server and file2 will be the document that will be generated.. both the documents have unique names..