I searched lots in internet to store the console application output screen in .txt file. I got the solution but i did not got the desired results. The problem is the text which was not display in console screen was stored in the notepad file. But the text displayed in the console screen was not stored in the notepad file.
For example,
using System;
using System.IO;
static void Main(string[] args)
{
Console.WriteLine("Text which is displayed in the the console output screen ");
FileStream filestream = new FileStream("notepad.txt", FileMode.Create);
var streamwriter = new StreamWriter(filestream);
streamwriter.AutoFlush = true;
Console.SetOut(streamwriter);
Console.SetError(streamwriter);
Console.WriteLine("Text which is not displayed in the console output screen but it store in the the .txt file");
Console.ReadKey();
}
In above example
The line Console.WriteLine("Text which is displayed in the the console output screen ");
is just displayed in the console screen but it was not store in the notepad file
But the line Console.WriteLine("Text which is not displayed in the console output screen but it store in the the .txt file");
is not displayed in the console application screen instead of it was stored in the notepad file.
I need to store everything whatever displayed in the console screen even user given details too.
How do I do it?
As I am a beginner, I expecting the answer would be simple.
Thanks in advance!