how can I write DIRECTLY into console, without bothering with stdout in c#? I’m upgrading some old program, which has it’s stdout redirected into file (because the output matters), and I need somehow to write directly to console, and that the text won’t appear in stdout. Is it possible (without using WinAPI)?
EDIT: I’m aware of the possibility to write to stderr, althrough, is it possible to set cursor position for stderr on console?
You could write to
Console.Error, which, although it can be redirected, is separate from stdout.Edit: Assuming that stderr has not been redirected, see
Console.CursorTopandConsole.CursorLeft. There’s various other members on theConsoleclass that you might find useful.To answer your question directly, use the Win32
WriteConsolefunction. As far as I can see, the .NET framework doesn’t have methods for writing directly to the console window.