开发者

control cmd.exe with c# (send and read outputs)

I want to send and receive commands like "dir" and so on 开发者_开发知识库but i can't manage to read the output


You have to redirect std in and std out. Once you do that, in C#, use the console as you would if you were writing a console app.

http://msdn.microsoft.com/en-us/library/3x859hf2(vs.71).aspx


If you are trying to execute an external application and capture the output you should look at this. The System.IO namespace has Directory, File, and Path classed which avoid the need to use external applications to enumerate directories.


You should not use console commands from code unless you really need to. (Hint: You don't)

You're looking for Directory.GetFiles.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜