从 Windows 窗体运行控制台应用程序
我有一个 Windows 控制台应用程序(接受参数)并运行一个进程。 我想知道是否有任何方法可以从 Windows 窗体按钮单击事件中运行此应用程序。 我也想向它传递一个论点。
谢谢
I have a windows console app (that accepts parameters) and runs a process.
I was wondering if there was any way to run this app from within a windows form button click event. I would like to pass an argument to it as well.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需将 System.Diagnostics.Process.Start 与控制台路径一起使用应用程序,参数作为第二个参数。
Just use System.Diagnostics.Process.Start with the path to the console application, and the parameters as the second argument.
假设您有一个带有名为 txtOutput 的多行文本框的表单......
Assuming you have a form with a multiline textbox called txtOutput.....
您需要使用 System.Diagnostics.Process
You'll want to use System.Diagnostics.Process