我在C#中调用的应用程序只能在控制cmd.exe下用命令行运行,请问在怎么实现
ascap 2006-06-17 02:25:54 我的程序只能在控制cmd.exe下用命令行运行,该程序的名称为convert.exe 而且还有3个参数需要传递给convert.exe,请问怎么实现。下面是我的代码,但不起作用。
string myAppPath = Application.StartupPath;
//this is exe file name
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.Arguments = myAppPath + "\\OfficeConverter.exe" +" /m" +myAppPath+"\\mydoc.doc"+ myAppPath + "\\mydoc.docx"; //parameters
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = false;
process.Start();
string strMsg = process.StandardOutput.ReadToEnd(); //exe output message.
process.Close();
谢谢大家先。