开发者

Use BeginOutputReadLine when the process output newline or return

I used Process() to execute a externa开发者_Go百科l file named "test.exe".

The "test.exe" only prints a string. "abc \n \r xyz\n"

My goal is to get the string and turn each byte to corresponding ASCII code.

That is, I expect the outputs in my c# console are as below, 97 98 99 32 10 32 13 32 120 121 122 10

But when I used BeginOutputReadLine to get the output of test.exe, \n and \r were striped.

As a result, I only got 97 98 99 32 32 32 120 121 122

Finally, I don't want to use synchronized ways like Read, ReadLine, and ReadToEnd. Is there any way to get what I want??

Thanks!

Actually, I create a backgroundWorker to deal with external process test.exe I have a proc_DataReceived and backgroundWorker_Build_ProgressChanged...

the related code as below

http://codepad.org/Gmq1XqXb

all code as below

http://codepad.org/k7VpWynu

(I'm new to stackoverflow. I pasted my code in codepad.org before finding out how to format code here.)


If you use BeginOutputReadLine, the string won't contain the "end of line" characters (or some of them).

See Capture output from unrelated process for another way to capture output of another process. This would work better in your case since you can read the stream character by character.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜