How to redirect a process output in direct ways?

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.
 
S

Stanimir Stoyanov

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();
 
F

free7942g

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! :)
 
F

free7942g

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! :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top