nic*_*cks 6 c# ipc asp.net-web-api .net-core asp.net-core
是否可以.exe
使用参数运行文件并从asp.net-core
自托管应用程序接收返回值?如果是 - 如何?
我尝试放入ConsoleApp1.exe
项目根文件夹并LaunchCommandLineApp
从Controller 调用,但它不起作用:exeProcess
填充错误的属性
static void LaunchCommandLineApp()
{
// For the example.
const string ex1 = "C:\\";
const string ex2 = "C:\\Dir";
// Use ProcessStartInfo class.
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "ConsoleApp1.exe";
//startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = "-f j -o \"" + ex1 + "\" -z 1.0 -s y " + ex2;
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using-statement will close.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch (Exception ex)
{
// Log error.
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1196 次 |
最近记录: |