Looking for some help to figure out on how can I save the output of my C# program into the word file?
- class Test
- {
- static void Main(string[] args)
- {
- Application app = new word.Application();
- Document doc = app.Documents.Open(filePath);
- ////Lines of Code
- Console.WriteLine(); //Output
- //How to save the above Console.Writeline in the word file??
- Doc.close();
- App.Quit(); } }

Sapna GirishRank #1,810 · 819 reputationPosted Jan 22, 2020, 2:03 AM EST
Ashutosh GuptaRank #805 · 2.9K reputationPosted Jan 22, 2020, 6:28 AM EST
Amit MohantyRank #112 · 20K reputationPosted Jan 23, 2020, 9:10 AM EST
Ram PrasadRank #4,848 · 322 reputationPosted Jan 29, 2020, 8:57 PM EST
Pusting72 reputationPosted Feb 4, 2020, 9:47 PM EST
So basically, this will redirect the Console.WriteLine to that StringWriter, but if you want to have the output text in both Console and in some String variable for you to use it, then you'll need to use Console.SetOut with something like this mirror writer:
Also, I'm using GemBox.Document to write into a DOCX file, for more info about that you can see:
Ram PrasadRank #4,848 · 322 reputationPosted Feb 10, 2020, 5:33 PM EST
Pusting72 reputationPosted Feb 10, 2020, 6:49 PM EST
Ram PrasadRank #4,848 · 322 reputationPosted Feb 12, 2020, 1:56 AM EST