从Windows窗体应用程序将多个参数传递给EXE

时间:2013-01-09 10:19:35

标签: c# winforms process inputstream windows-applications

我有一个app.exe应用程序要求输入输入路径字符串,一旦我输入,它会询问输出路径字符串...现在当我输入时,app .exe执行一些操作

我需要从我的窗体应用程序传递这些路径 我看到很多这样的问题,但无法实现我的要求,因为我从未使用过程和Stream Reader或Writer 任何帮助请...示例将被感谢..谢谢..

        string input = @"C:\Documents and Settings\pankaj\Desktop\My File\greetingsfreinds.ppt";
        string output = @"C:\Documents and Settings\pankaj\Desktop\test";
        Process process = new Process();
        process.StartInfo.FileName = @"C:\Program Files\Wondershare\MyApp\app.exe";
        process.StartInfo.UseShellExecute = false;
        process.StartInfo.CreateNoWindow = false;
        process.StartInfo.RedirectStandardInput = true;
        process.Start();
        process.WaitForExit(3000);
        process.Close();

好吧,我试过了 但它给了一些例外 StandardOut尚未重定向或流程尚未开始 ...   我的代码是

        string input = @"C:\Documents and Settings\pankaj\Desktop\My File\greetingsfreinds.ppt";
        string output = @"C:\Documents and Settings\pankaj\Desktop\test";
        Process process = new Process();
        process.StartInfo.FileName = @"C:\Program Files\Wondershare\MyApp\app.exe";
        process.StartInfo.UseShellExecute = false;
        process.StartInfo.CreateNoWindow = false;
        process.StartInfo.RedirectStandardInput = true;
        process.StartInfo.Arguments = input + ";" + output;
        process.Start();
        string Strout = process.StandardOutput.ReadToEnd();
        process.WaitForExit();
        process.Close();

1 个答案:

答案 0 :(得分:6)

您可以使用ProcessStartInfo.Arguments

    Process process = new Process()
    process.StartInfo.FileName = @"C:\Program Files\Wondershare\MyApp\app.exe";
    process.StartInfo.UseShellExecute = false;
    ....
    process.Arguments = input + " " + output;