Hello,
Thank you for your inquiry.
I simulated two Word documents and tested your code using the latest version of Spire.Doc(
Spire.Doc Pack(hot fix) Version:11.5.12), but I couldn't reproduce the issue you mentioned. If you are not using the latest version, please test with it first. If the issue still exists after testing, please provide your source Word file and your application type(such as Console app .Net Framework 4.5) for further investigation. You could attach them here or send them to us via email (
[email protected]). Thanks in advance.
Additionally, you can use the following code to merge Word files.
- Code: Select all
Document doc = new Document(path);
foreach (string element in filePaths)
{
if (File.Exists(element))
{
Document newDoc = new Document();
newDoc.LoadFromFile(element, FileFormat.Auto);
newDoc.KeepSameFormat = true;
foreach (Section section in newDoc.Sections)
{
doc.Sections.Add(section.Clone());
}
}
}
doc.SaveToFile($"{output}{fileName}{fileExtension}", FileFormat.Docx2013);
Sincerely,
Annika
E-iceblue support team