diff --git a/Performance-metrices/Find-and-Replace/.NET/Find-and-Replace/Find-and-Replace.slnx b/Performance-metrices/Find-and-Replace/.NET/Find-and-Replace/Find-and-Replace.slnx
new file mode 100644
index 000000000..83bc4aed0
--- /dev/null
+++ b/Performance-metrices/Find-and-Replace/.NET/Find-and-Replace/Find-and-Replace.slnx
@@ -0,0 +1,3 @@
+
+
+
diff --git a/Performance-metrices/Find-and-Replace/.NET/Find-and-Replace/Find-and-Replace/Data/Template.docx b/Performance-metrices/Find-and-Replace/.NET/Find-and-Replace/Find-and-Replace/Data/Template.docx
new file mode 100644
index 000000000..c83b0a198
Binary files /dev/null and b/Performance-metrices/Find-and-Replace/.NET/Find-and-Replace/Find-and-Replace/Data/Template.docx differ
diff --git a/Performance-metrices/Find-and-Replace/.NET/Find-and-Replace/Find-and-Replace/Find-and-Replace.csproj b/Performance-metrices/Find-and-Replace/.NET/Find-and-Replace/Find-and-Replace/Find-and-Replace.csproj
new file mode 100644
index 000000000..5a7317ce9
--- /dev/null
+++ b/Performance-metrices/Find-and-Replace/.NET/Find-and-Replace/Find-and-Replace/Find-and-Replace.csproj
@@ -0,0 +1,24 @@
+
+
+
+ Exe
+ net8.0
+ Find_and_Replace
+ enable
+ enable
+
+
+
+
+
+
+
+
+ Always
+
+
+ Always
+
+
+
+
diff --git a/Performance-metrices/Find-and-Replace/.NET/Find-and-Replace/Find-and-Replace/Output/.gitkeep b/Performance-metrices/Find-and-Replace/.NET/Find-and-Replace/Find-and-Replace/Output/.gitkeep
new file mode 100644
index 000000000..5f282702b
--- /dev/null
+++ b/Performance-metrices/Find-and-Replace/.NET/Find-and-Replace/Find-and-Replace/Output/.gitkeep
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Performance-metrices/Find-and-Replace/.NET/Find-and-Replace/Find-and-Replace/Program.cs b/Performance-metrices/Find-and-Replace/.NET/Find-and-Replace/Find-and-Replace/Program.cs
new file mode 100644
index 000000000..e6cbc1007
--- /dev/null
+++ b/Performance-metrices/Find-and-Replace/.NET/Find-and-Replace/Find-and-Replace/Program.cs
@@ -0,0 +1,33 @@
+using Syncfusion.DocIO;
+using Syncfusion.DocIO.DLS;
+using System.Diagnostics;
+
+namespace Find_and_replace_in_a_worddocument
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
+ {
+ //Open the template Word document.
+ using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Automatic))
+ {
+ Stopwatch stopwatch = new Stopwatch();
+ stopwatch.Start();
+ //Find all occurrences of a misspelled word and replaces with properly spelled word
+ int replacedCount = document.Replace("document", "DocIO", false, false);
+ stopwatch.Stop();
+ Console.WriteLine(replacedCount);
+ Console.WriteLine($"Time taken for Replace (string):" + stopwatch.Elapsed.TotalSeconds);
+ //Create file stream
+ using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
+ {
+ //Save the Word document to file stream
+ document.Save(outputFileStream, FormatType.Docx);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/Performance-metrices/Open-and-save/.NET/Open-and-Save-Word-document/Open-and-Save-Word-document/Output/.gitkeep b/Performance-metrices/Open-and-save/.NET/Open-and-Save-Word-document/Open-and-Save-Word-document/Output/.gitkeep
new file mode 100644
index 000000000..5f282702b
--- /dev/null
+++ b/Performance-metrices/Open-and-save/.NET/Open-and-Save-Word-document/Open-and-Save-Word-document/Output/.gitkeep
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/Performance-metrices/Open-and-save/.NET/Open-and-Save-Word-document/Open-and-Save-Word-document/Program.cs b/Performance-metrices/Open-and-save/.NET/Open-and-Save-Word-document/Open-and-Save-Word-document/Program.cs
index d2c75d3d8..37ec109b8 100644
--- a/Performance-metrices/Open-and-save/.NET/Open-and-Save-Word-document/Open-and-Save-Word-document/Program.cs
+++ b/Performance-metrices/Open-and-save/.NET/Open-and-Save-Word-document/Open-and-Save-Word-document/Program.cs
@@ -8,35 +8,22 @@ class Program
{
static void Main()
{
- string inputFolder = Path.GetFullPath("../../../Data/");
- string outputFolder = Path.GetFullPath("../../../Output/");
- Directory.CreateDirectory(outputFolder);
-
- // Get all .docx files in the Data folder
- string[] files = Directory.GetFiles(inputFolder, "*.docx");
-
- foreach (string inputPath in files)
+ Stopwatch stopwatch = Stopwatch.StartNew();
+ //Open a file as a stream.
+ using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
- string fileName = Path.GetFileName(inputPath);
- string outputPath = Path.Combine(outputFolder, fileName);
-
- Stopwatch stopwatch = Stopwatch.StartNew();
-
- try
- {
- // Load or open Word document
- WordDocument document = new WordDocument(inputPath);
-
- // Save the Word document to Output folder
- document.Save(outputPath);
- stopwatch.Stop();
- Console.WriteLine($"{fileName} open and saved in {stopwatch.Elapsed.TotalSeconds} seconds");
- document.Close();
- }
- catch (Exception ex)
+ //Load the file stream into a Word document.
+ using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx))
{
- Console.WriteLine($"Error processing {fileName}: {ex.Message}");
+ //Create a file stream.
+ using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
+ {
+ //Save a Markdown file to the file stream.
+ document.Save(outputFileStream, FormatType.Docx);
+ stopwatch.Stop();
+ Console.WriteLine($"Time taken to open and save a 100-page document: {stopwatch.Elapsed.TotalSeconds} seconds");
+ }
}
}
}