C# Send Commands

2019-06-25 11:37发布

I have a command line program running and I would like to send additional commands to it (I.E. Once it is already running) How can I do this in C#?

3条回答
聊天终结者
2楼-- · 2019-06-25 12:01

If the process is started by your C# program, then you can use Process.StandardInput to send commands to it.

If you are sending command to other processes, you can use the SendKey class as demoed in here.

查看更多
一夜七次
3楼-- · 2019-06-25 12:12

If you are talking about an interactive console program you just need to use Console.Readline() to get the input from the console and process it in your code. If you are talking about something more complex read about Inter-process communication (IPC).

查看更多
登录 后发表回答