Skip to content

Commit bae990e

Browse files
Modified sample
1 parent 4e4eb94 commit bae990e

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

  • Performance-metrices/Clone-and-merge/.NET/Clone-and-merge-word-document/Clone-and-merge-word-document

Performance-metrices/Clone-and-merge/.NET/Clone-and-merge-word-document/Clone-and-merge-word-document/Program.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@ static void Main()
1010
{
1111
using (FileStream destinationFileStream = new FileStream(Path.GetFullPath(@"Data/DestinationDocument/Document-100.docx"), FileMode.Open, FileAccess.Read))
1212
{
13-
WordDocument mainDoc = new WordDocument(sourceFileStream, FormatType.Docx);
14-
WordDocument mergeDoc = new WordDocument(destinationFileStream, FormatType.Docx);
15-
Stopwatch sw = Stopwatch.StartNew();
16-
mainDoc.ImportContent(mergeDoc, ImportOptions.UseDestinationStyles);
17-
sw.Stop();
18-
Console.WriteLine("Time taken for Merge Documents:" + sw.Elapsed.TotalSeconds);
19-
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/MergedDocument.docx"), FileMode.Create))
13+
using (WordDocument mainDoc = new WordDocument(sourceFileStream, FormatType.Docx))
2014
{
21-
mainDoc.Save(outputFileStream, FormatType.Docx);
22-
}
23-
mainDoc.Close();
24-
mergeDoc.Close();
15+
using (WordDocument mergeDoc = new WordDocument(destinationFileStream, FormatType.Docx))
16+
{
17+
Stopwatch sw = Stopwatch.StartNew();
18+
mainDoc.ImportContent(mergeDoc, ImportOptions.UseDestinationStyles);
19+
sw.Stop();
20+
Console.WriteLine("Time taken for Merge Documents:" + sw.Elapsed.TotalSeconds);
21+
using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/MergedDocument.docx"), FileMode.Create))
22+
{
23+
mainDoc.Save(outputFileStream, FormatType.Docx);
24+
}
25+
}
26+
}
2527
}
2628
}
2729
}

0 commit comments

Comments
 (0)