开发者

How to discard (reset) process.standardoutput in .NET?

Any ideas on how to discard or reset the contents in a Process.StandardOutput, so we can discard the 开发者_JS百科message of the day and any other initial content of a process?


You could to try something similar to:

Process.StandardOutput.BaseStream.SetLength(0);

process.StandardOutput.ReadToEnd();

That way you'll read all content already written and to ignore it. Since that stream doesn't supports seek operations, you user will receive a "headerless" stream.


Does Process.StandardOutput.DiscardBufferedData() not do what you want?

Alternatively just read from it until it's empty? Not very efficient I guess, but if it's just title fluff then it'll be one read.


I don't know what you mean by discard but you may redirect the standard output:

When a Process writes text to its standard stream, that text is typically displayed on the console. By redirecting the StandardOutput stream, you can manipulate or suppress the output of a process.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜