gpt4 book ai didi

c# - 从 Windows 窗体应用程序向 EXE 传递多个参数

转载 作者:可可西里 更新时间:2023-11-01 11:08:42 26 4
gpt4 key购买 nike

我有一个 app.exe 应用程序要求输入 input path 字符串,一旦我输入,它会询问 output path 字符串...现在当我输入时,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();

好的,我试过了但它给出了一些异常(exception)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();

最佳答案

您可以使用 ProcessStartInfo.Arguments为此。

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

关于c# - 从 Windows 窗体应用程序向 EXE 传递多个参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14232960/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com