From 2a8b29b93ff4348cb840acdb83ee5ab200e3b94c Mon Sep 17 00:00:00 2001 From: DharanyaSakthivel-SF4210 Date: Tue, 10 Sep 2024 23:33:54 +0530 Subject: [PATCH] Feedback addressed --- .../.NET/Add_toc_in_merged_documents/Program.cs | 4 ++-- .../.NET/Apply-picture-background-to-document/Program.cs | 2 +- .../Copy-Excel-content-to-Word-with-formatting/Program.cs | 4 ++-- .../.NET/Find-and-replace-text-with-Excel-content/Program.cs | 4 ++-- .../Merge-documents-with-same-header-and-footer/Program.cs | 2 +- .../.NET/Merge-without-changing-page-numbers/Program.cs | 2 +- .../Program.cs" | 4 ++-- .../.NET/Modify-formatting-for-default-styles/Program.cs | 4 ++-- .../.NET/Remove-empty-pages-from-Word-document/Program.cs | 4 ++-- .../Split-by-heading/.NET/Split-by-heading/Program.cs | 4 ++-- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Table-Of-Contents/Add_toc_in_merged_documents/.NET/Add_toc_in_merged_documents/Program.cs b/Table-Of-Contents/Add_toc_in_merged_documents/.NET/Add_toc_in_merged_documents/Program.cs index 9eb5d711..70653ea2 100644 --- a/Table-Of-Contents/Add_toc_in_merged_documents/.NET/Add_toc_in_merged_documents/Program.cs +++ b/Table-Of-Contents/Add_toc_in_merged_documents/.NET/Add_toc_in_merged_documents/Program.cs @@ -3,7 +3,7 @@ using Syncfusion.DocIORenderer; //Get the Source document names from the folder. -string[] sourceDocumentNames = Directory.GetFiles(@"Data/"); +string[] sourceDocumentNames = Directory.GetFiles(Path.GetFullPath(@"Data/")); //Create an WordDocumentinstance for destination document. using (WordDocument destinationDocument = new WordDocument()) @@ -34,7 +34,7 @@ //Updates the table of contents destinationDocument.UpdateTableOfContents(); //Save the destination document. - using (FileStream outputStream = new FileStream(@"Output/Output.docx", FileMode.Create, FileAccess.Write)) + using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.Write)) { destinationDocument.Save(outputStream, FormatType.Docx); } diff --git a/Word-document/Apply-picture-background-to-document/.NET/Apply-picture-background-to-document/Program.cs b/Word-document/Apply-picture-background-to-document/.NET/Apply-picture-background-to-document/Program.cs index 115a004d..316f688d 100644 --- a/Word-document/Apply-picture-background-to-document/.NET/Apply-picture-background-to-document/Program.cs +++ b/Word-document/Apply-picture-background-to-document/.NET/Apply-picture-background-to-document/Program.cs @@ -16,7 +16,7 @@ static void Main(string[] args) //Sets the background type as picture. document.Background.Type = BackgroundType.Picture; //Opens the existing image. - using (FileStream imageStream = new FileStream(@"Data/Picture.png", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (FileStream imageStream = new FileStream(Path.GetFullPath(@"Data/Picture.png"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (MemoryStream memoryStream = new MemoryStream()) { diff --git a/Word-document/Copy-Excel-content-to-Word-with-formatting/.NET/Copy-Excel-content-to-Word-with-formatting/Program.cs b/Word-document/Copy-Excel-content-to-Word-with-formatting/.NET/Copy-Excel-content-to-Word-with-formatting/Program.cs index 12184127..53140ca8 100644 --- a/Word-document/Copy-Excel-content-to-Word-with-formatting/.NET/Copy-Excel-content-to-Word-with-formatting/Program.cs +++ b/Word-document/Copy-Excel-content-to-Word-with-formatting/.NET/Copy-Excel-content-to-Word-with-formatting/Program.cs @@ -18,7 +18,7 @@ ExtractExcelContent(table); //Load the file into stream -FileStream outputStream = new FileStream("Output/Output.docx", FileMode.Create, FileAccess.Write); +FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.Write); //Save the Word document. document.Save(outputStream, FormatType.Docx); //Close the document @@ -35,7 +35,7 @@ void ExtractExcelContent(WTable table) IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; //Load the file into stream - FileStream inputExcelStream = new FileStream("Data/Sample.xlsx", FileMode.Open, FileAccess.Read); + FileStream inputExcelStream = new FileStream(Path.GetFullPath(@"Data/Sample.xlsx"), FileMode.Open, FileAccess.Read); IWorkbook workbook = application.Workbooks.Open(inputExcelStream); //Get the first worksheet diff --git a/Word-document/Find-and-replace-text-with-Excel-content/.NET/Find-and-replace-text-with-Excel-content/Program.cs b/Word-document/Find-and-replace-text-with-Excel-content/.NET/Find-and-replace-text-with-Excel-content/Program.cs index aded7192..5f868cac 100644 --- a/Word-document/Find-and-replace-text-with-Excel-content/.NET/Find-and-replace-text-with-Excel-content/Program.cs +++ b/Word-document/Find-and-replace-text-with-Excel-content/.NET/Find-and-replace-text-with-Excel-content/Program.cs @@ -24,7 +24,7 @@ document.Replace("<>", bodyPart, true, true, false); //Load the file into stream - FileStream outputStream = new FileStream("Output/Output.docx", FileMode.Create, FileAccess.Write); + FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.Write); //Save the Word document. document.Save(outputStream, FormatType.Docx); } @@ -40,7 +40,7 @@ void ExtractExcelContent(WTable table) IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Xlsx; //Load the file into stream - FileStream inputExcelStream = new FileStream("Data/Sample.xlsx", FileMode.Open, FileAccess.Read); + FileStream inputExcelStream = new FileStream(Path.GetFullPath(@"Data/Sample.xlsx"), FileMode.Open, FileAccess.Read); IWorkbook workbook = application.Workbooks.Open(inputExcelStream); //Get the first worksheet diff --git a/Word-document/Merge-documents-with-same-header-and-footer/.NET/Merge-documents-with-same-header-and-footer/Program.cs b/Word-document/Merge-documents-with-same-header-and-footer/.NET/Merge-documents-with-same-header-and-footer/Program.cs index b44b905e..37513e83 100644 --- a/Word-document/Merge-documents-with-same-header-and-footer/.NET/Merge-documents-with-same-header-and-footer/Program.cs +++ b/Word-document/Merge-documents-with-same-header-and-footer/.NET/Merge-documents-with-same-header-and-footer/Program.cs @@ -18,7 +18,7 @@ static void Main(string[] args) using (WordDocument destinationDocument = new WordDocument(destinationStreamPath, FormatType.Automatic)) { //Get the Source document names from the folder. - string[] sourceDocumentNames = Directory.GetFiles(@"Data/SourceDocuments/"); + string[] sourceDocumentNames = Directory.GetFiles(Path.GetFullPath(@"Data/SourceDocuments/"));                     //Merge each source document to the destination document. foreach (string subDocumentName in sourceDocumentNames) { diff --git a/Word-document/Merge-without-changing-page-numbers/.NET/Merge-without-changing-page-numbers/Program.cs b/Word-document/Merge-without-changing-page-numbers/.NET/Merge-without-changing-page-numbers/Program.cs index 171102cd..8e738cb4 100644 --- a/Word-document/Merge-without-changing-page-numbers/.NET/Merge-without-changing-page-numbers/Program.cs +++ b/Word-document/Merge-without-changing-page-numbers/.NET/Merge-without-changing-page-numbers/Program.cs @@ -17,7 +17,7 @@ static void Main(string[] args) using (WordDocument destinationDocument = new WordDocument(destinationStreamPath, FormatType.Automatic)) { //Get the Source document names from the folder. - string[] sourceDocumentNames = Directory.GetFiles(@"Data/SourceDocuments/"); + string[] sourceDocumentNames = Directory.GetFiles(Path.GetFullPath(@"Data/SourceDocuments/")); foreach (string subDocumentName in sourceDocumentNames) { //Open the source document files as a stream. diff --git "a/Word-document/Merge\342\200\223multiple-Word-files-in-same-page/.NET/Merge\342\200\223multiple-Word-files-in-same-page/Program.cs" "b/Word-document/Merge\342\200\223multiple-Word-files-in-same-page/.NET/Merge\342\200\223multiple-Word-files-in-same-page/Program.cs" index c44d8961..328b9827 100644 --- "a/Word-document/Merge\342\200\223multiple-Word-files-in-same-page/.NET/Merge\342\200\223multiple-Word-files-in-same-page/Program.cs" +++ "b/Word-document/Merge\342\200\223multiple-Word-files-in-same-page/.NET/Merge\342\200\223multiple-Word-files-in-same-page/Program.cs" @@ -8,7 +8,7 @@ sourceFileNames.Add("Data/Salutation.docx"); sourceFileNames.Add("Data/Greetings.docx"); -string destinationFileName = "Data/Title.docx"; +string destinationFileName = Path.GetFullPath(@"Data/Title.docx"); using (FileStream destinationStreamPath = new FileStream(destinationFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { //Opens the destination document @@ -16,7 +16,7 @@ { ImportOtherDocuments(sourceFileNames, destinationDocument); //Saves and closes the destination document - using (FileStream outputStream = new FileStream("Output/Output.docx", FileMode.Create, FileAccess.Write)) + using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.Write)) { destinationDocument.Save(outputStream, FormatType.Docx); destinationDocument.Close(); diff --git a/Word-document/Modify-formatting-for-default-styles/.NET/Modify-formatting-for-default-styles/Program.cs b/Word-document/Modify-formatting-for-default-styles/.NET/Modify-formatting-for-default-styles/Program.cs index 51edf9b1..06abf35c 100644 --- a/Word-document/Modify-formatting-for-default-styles/.NET/Modify-formatting-for-default-styles/Program.cs +++ b/Word-document/Modify-formatting-for-default-styles/.NET/Modify-formatting-for-default-styles/Program.cs @@ -1,7 +1,7 @@ using Syncfusion.DocIO; using Syncfusion.DocIO.DLS; -using (FileStream fileStreamPath = new FileStream(@"Data/Input.docx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) +using (FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { //Open the existing Word document. using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx)) @@ -12,7 +12,7 @@ ChangeParagraphFormatting(document); //Change table style formatting ChangeTableFormatting(document); - using (FileStream outputStream = new FileStream(@"Output/Output.docx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite)) + using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite)) { //Save the Word document. document.Save(outputStream, FormatType.Docx); diff --git a/Word-document/Remove-empty-pages-from-Word-document/.NET/Remove-empty-pages-from-Word-document/Program.cs b/Word-document/Remove-empty-pages-from-Word-document/.NET/Remove-empty-pages-from-Word-document/Program.cs index 8bb2af93..fd400b98 100644 --- a/Word-document/Remove-empty-pages-from-Word-document/.NET/Remove-empty-pages-from-Word-document/Program.cs +++ b/Word-document/Remove-empty-pages-from-Word-document/.NET/Remove-empty-pages-from-Word-document/Program.cs @@ -3,7 +3,7 @@ //Opens an existing Word document -using (FileStream inputStream = new FileStream("Data/Sample.docx", FileMode.Open, FileAccess.Read)) +using (FileStream inputStream = new FileStream(Path.GetFullPath(@"Data/Sample.docx"), FileMode.Open, FileAccess.Read)) { using (WordDocument document = new WordDocument(inputStream, FormatType.Docx)) { @@ -22,7 +22,7 @@ document.ChildEntities.RemoveAt(SectionIndex); } } - using (FileStream outputStream = new FileStream("Output/Output.docx", FileMode.Create, FileAccess.Write)) + using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Output.docx"), FileMode.Create, FileAccess.Write)) { //Saves and closes the Word document document.Save(outputStream, FormatType.Docx); diff --git a/Word-document/Split-by-heading/.NET/Split-by-heading/Program.cs b/Word-document/Split-by-heading/.NET/Split-by-heading/Program.cs index dfc3e9bd..d5c5dcf3 100644 --- a/Word-document/Split-by-heading/.NET/Split-by-heading/Program.cs +++ b/Word-document/Split-by-heading/.NET/Split-by-heading/Program.cs @@ -37,7 +37,7 @@ static void Main(string[] args) if (newDocument != null) { //Saves the Word document - string fileName = @"Output/Document" + (headingIndex + 1) + ".docx"; + string fileName = Path.GetFullPath(@"Output/Document") + (headingIndex + 1) + ".docx"; SaveWordDocument(newDocument, fileName); headingIndex++; } @@ -57,7 +57,7 @@ static void Main(string[] args) if (newDocument != null) { //Saves the Word document - string fileName = @"Output/Document" + (headingIndex + 1) + ".docx"; + string fileName = Path.GetFullPath(@"Output/Document") + (headingIndex + 1) + ".docx"; SaveWordDocument(newDocument, fileName); } }