diff --git a/Performance-metrices/Clone-and-merge/.NET/Clone-and-merge-word-document/Clone-and-merge-word-document/Clone-and-merge-word-document.csproj b/Performance-metrices/Clone-and-merge/.NET/Clone-and-merge-word-document/Clone-and-merge-word-document/Clone-and-merge-word-document.csproj
index ad8c6950f..bb91546fb 100644
--- a/Performance-metrices/Clone-and-merge/.NET/Clone-and-merge-word-document/Clone-and-merge-word-document/Clone-and-merge-word-document.csproj
+++ b/Performance-metrices/Clone-and-merge/.NET/Clone-and-merge-word-document/Clone-and-merge-word-document/Clone-and-merge-word-document.csproj
@@ -11,5 +11,15 @@
-
+
+
+ Always
+
+
+ Always
+
+
+ Always
+
+
diff --git a/Performance-metrices/Clone-and-merge/.NET/Clone-and-merge-word-document/Clone-and-merge-word-document/Output/.gitkeep b/Performance-metrices/Clone-and-merge/.NET/Clone-and-merge-word-document/Clone-and-merge-word-document/Output/.gitkeep
new file mode 100644
index 000000000..5f282702b
--- /dev/null
+++ b/Performance-metrices/Clone-and-merge/.NET/Clone-and-merge-word-document/Clone-and-merge-word-document/Output/.gitkeep
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Performance-metrices/Clone-and-merge/.NET/Clone-and-merge-word-document/Clone-and-merge-word-document/Program.cs b/Performance-metrices/Clone-and-merge/.NET/Clone-and-merge-word-document/Clone-and-merge-word-document/Program.cs
index 1a814477c..fa1f34447 100644
--- a/Performance-metrices/Clone-and-merge/.NET/Clone-and-merge-word-document/Clone-and-merge-word-document/Program.cs
+++ b/Performance-metrices/Clone-and-merge/.NET/Clone-and-merge-word-document/Clone-and-merge-word-document/Program.cs
@@ -1,5 +1,4 @@
-using System.ComponentModel;
-using System.Diagnostics;
+using System.Diagnostics;
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
@@ -7,55 +6,25 @@ class Program
{
static void Main()
{
- string sourceFolder = Path.GetFullPath("../../../Data/SourceDocument/");
- string destinationFolder = Path.GetFullPath("../../../Data/DestinationDocument/");
- string outputFolder = Path.GetFullPath("../../../Output/");
-
- Directory.CreateDirectory(outputFolder);
-
- // Get all source files
- string[] sourceFiles = Directory.GetFiles(sourceFolder, "*.docx");
-
- foreach (string sourcePath in sourceFiles)
+ using (FileStream sourceFileStream = new FileStream(Path.GetFullPath(@"Data/SourceDocument/Document-100.docx"), FileMode.Open, FileAccess.Read))
{
- string fileName = Path.GetFileName(sourcePath);
- string destinationPath = Path.Combine(destinationFolder, fileName);
-
- if (!File.Exists(destinationPath))
- {
- Console.WriteLine($"Skipping {fileName} - No matching destination file found.");
- continue;
- }
-
- string outputPath = Path.Combine(outputFolder, fileName);
-
- Stopwatch stopwatch = Stopwatch.StartNew();
-
- try
+ using (FileStream destinationFileStream = new FileStream(Path.GetFullPath(@"Data/DestinationDocument/Document-100.docx"), FileMode.Open, FileAccess.Read))
{
- // Open source and destination document
- WordDocument sourceDocument = new WordDocument(sourcePath);
- WordDocument destinationDocument = new WordDocument(destinationPath);
-
- // Clone and merge all slides
- foreach (WSection section in sourceDocument.Sections)
+ using (WordDocument mainDoc = new WordDocument(sourceFileStream, FormatType.Docx))
{
- WSection clonedSection = section.Clone();
- destinationDocument.Sections.Add(clonedSection);
- }
-
- // Save the merged document.
- destinationDocument.Save(outputPath);
-
- stopwatch.Stop();
- Console.WriteLine($"{fileName} is cloned and merged in {stopwatch.Elapsed.TotalSeconds} seconds.");
- sourceDocument.Close();
- destinationDocument.Close();
- }
- catch (Exception ex)
- {
- Console.WriteLine($"Error processing {fileName}: {ex.Message}");
+ using (WordDocument mergeDoc = new WordDocument(destinationFileStream, FormatType.Docx))
+ {
+ Stopwatch sw = Stopwatch.StartNew();
+ mainDoc.ImportContent(mergeDoc, ImportOptions.UseDestinationStyles);
+ sw.Stop();
+ Console.WriteLine("Time taken for Merge Documents:" + sw.Elapsed.TotalSeconds);
+ using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/MergedDocument.docx"), FileMode.Create))
+ {
+ mainDoc.Save(outputFileStream, FormatType.Docx);
+ }
+ }
+ }
}
}
}
-}
+}
\ No newline at end of file