How to redirect a process output in direct ways?

  • Thread starter Thread starter free7942g
  • Start date Start date
F

free7942g

I have a console application that has huge outputs.

I want to redirect the standard i/o to files, directly.
but Process class has only process pipes.

Do I have to CreateProcess API?
I will use this code for server.

Any Idea, please.

Thank you.
 
You can use the Console.SetOut method to redirect output to a file stream
but before the console application exits you should flush or close the
stream to ensure that any data smaller than the default buffer is appended
to the file.

using System.IO;
// ...
StreamWriter stream = new StreamWriter(@"C:\temp\test.txt");
Console.SetOut(stream);

stream.Close();
 
You can use the Console.SetOut method to redirect output to a file stream
but before the console application exits you should flush or close the
stream to ensure that any data smaller than the default buffer is appended
to the file.

using System.IO;
// ...
StreamWriter stream = new StreamWriter(@"C:\temp\test.txt");
Console.SetOut(stream);

stream.Close();

--
Stanimir Stoyanovhttp://stoyanoff.info












- µû¿Â ÅؽºÆ® º¸±â -

A problem was solved because of you.
Oh, I am using a translation program.
Thanks very much! :-)
 
You can use the Console.SetOut method to redirect output to a file stream
but before the console application exits you should flush or close the
stream to ensure that any data smaller than the default buffer is appended
to the file.

using System.IO;
// ...
StreamWriter stream = new StreamWriter(@"C:\temp\test.txt");
Console.SetOut(stream);

stream.Close();

--
Stanimir Stoyanovhttp://stoyanoff.info












- µû¿Â ÅؽºÆ® º¸±â -

Oh, I am using translating software...
Thanks very much! :-)
 
Back
Top