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

Pan*_*bey 1 c# inputstream process winforms 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();
Run Code Online (Sandbox Code Playgroud)

好吧,我试过,但它给了一些例外 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();
Run Code Online (Sandbox Code Playgroud)

Tig*_*ran 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;
Run Code Online (Sandbox Code Playgroud)