Reputation: 2177
I'm trying to stream binary data to the standard output in .NET. However you can only write char using the Console class. I want to use it with redirection. Is there a way to do this?
Upvotes: 4
Views: 2601
Reputation: 71013
You can access the output stream using Console.OpenStandardOutput
.
static void Main(string[] args) {
MemoryStream data = new MemoryStream(Encoding.UTF8.GetBytes("Some data"));
using (Stream console = Console.OpenStandardOutput()) {
data.CopyTo(console);
}
}
Upvotes: 6