0
我在桌面上有一個名爲DocToPDF.exe的控制檯應用程序。我需要在Web應用程序的按鈕點擊上運行它。我想出瞭如何運行該應用程序。現在的問題是,控制檯應用程序需要一隻argument.I需要弄清楚傳遞要傳遞的argument.The參數的方法是「3750」這是我的代碼通過使用Web應用程序提供一個參數來運行控制檯應用程序
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......... ");
的可能的複製[如何參數傳遞給在C#中另一個進程(http://stackoverflow.com/questions/16057063/如何對-p ass-parameters-to-another-process-in-c-sharp) – tnw
你爲什麼要啓動'cmd'並傳遞'DocToPDF.exe'?你不能直接啓動「DocToPDF.exe」嗎?然後傳遞它的參數? –
在.exe後面使用空格,然後傳遞參數。 'process.StartInfo.Arguments =「/ c \」「+」DocToPDF.exe「+」\「」+「3750」;' – Ian