A user is being asked if he / she likes to save the cmd output into a .txt-file. If this condition is true, StreamWriter
starts "listening" to the cmd output until a certain point, then saves it into a .txt-file.
StreamWriter
should not redirect the output; it should appear in the cmd as well the specific part in the .txt-file.
Use this excerpt to get an overview over my code:
if(choice == 1)
{
write = WriteFile.Exists(path, id); // In this method the user confirms if he likes to save the following output to the .txt-File
if(write == true)
{
// START LISTENING TO OUTPUT
}
}
// Algorithm which searches for an ID
Console.WriteLine("The ID was {0}", id);
if(write == true)
{
// STOP LISTENING and SAVE
}
Is it possible to realize my inquriy in an easy way?