【发布时间】:2016-01-06 15:56:46
【问题描述】:
我在桌面上有一个名为 DocToPDF.exe 的控制台应用程序。我需要在单击 Web 应用程序的按钮时运行它。我想出了如何运行该应用程序。问题是,控制台应用程序需要一个参数。我需要弄清楚传递参数的方式。要传递的参数是“3750”这是我的代码
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "cmd";
process.StartInfo.WorkingDirectory = @"C:\Users\itadmin\Desktop\DocToPDF\DocToPDF\DocToPDF\bin\Debug";
process.StartInfo.Arguments= "/c \"" + "DocToPDF.exe" + "\"";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.Start();
这是我的控制台应用程序,它使用 Console.Readline 接受参数
Console.Write("Enter Merchant Acct # : ");
string strApprId = Console.ReadLine();
strApprId = strApprId.Trim();
Console.WriteLine("Something awesome is being processed......... ");
【问题讨论】:
-
你为什么从
cmd开始,然后通过DocToPDF.exe?不能直接启动DocToPDF.exe吗?然后传递参数? -
在 .exe 后使用空格,然后传递参数。
process.StartInfo.Arguments= "/c \"" + "DocToPDF.exe" + "\"" + " 3750"; -
我尝试直接传递DocToPDF.exe,但它不接受参数。
标签: c# asp.net console-application