How to save the output of a console application

后端 未结 6 1163
有刺的猬
有刺的猬 2021-01-11 19:12

I need advice on how to have my C# console application display text to the user through the standard output while still being able access it later on. The actual feature I w

6条回答
  •  旧时难觅i
    2021-01-11 20:15

    I don't think there's anything wrong with your approach.

    If you wanted reusable code, consider implementing a class called MultiWriter or somesuch that takes as input two (or N?) TextWriter streams and distributes all writs, flushes, etc. to those streams. Then you can do this file/console thing, but just as easily you can split any output stream. Useful!

提交回复
热议问题