简体   繁体   English

单击按钮在Windows应用程序上运行控制台应用程序

[英]Running console application on windows application with button click

I am trying to run a Console Application from a Windows Application. 我正在尝试从Windows应用程序运行控制台应用程序。 This Windows Application acts as a user interface. 该Windows应用程序充当用户界面。 So when you click on a specific button, the new process (myConsoleApp.exe) will start. 因此,当您单击特定按钮时,新过程(myConsoleApp.exe)将启动。 My question is where should I put myConsoleApp.exe? 我的问题是应该将myConsoleApp.exe放在哪里? I am using Visual Studio 2013. Should I put it in the same folder as my windows app? 我正在使用Visual Studio2013。是否应该将其与Windows应用程序放在同一文件夹中? Or somewhere more specific for the following code to work properly. 或者更具体的地方,以下代码可以正常工作。

public void Button_Click(object sender, RoutedEventArgs e)
{
     Process p = new Process();
     p.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + "myConsoleApp.exe";
     p.StartInfo.Arguments = name.Text;
     p.Start();
}

Thank you in advance for your help. 预先感谢您的帮助。

Put it anywhere you want just specify the "WorkingDirectory". 只需将其指定在“ WorkingDirectory”即可。

Process p = new Process();
p.WorkingDirectory = "path";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM