运行 带有来自文本文件的参数的 exe

Run an exe with arguments that come from a text file

正如标题所说,我正在尝试 运行 一个来自 TXT 文件(在资源中)的带有 parameters/arguments 的 EXE 我知道如何启动一个带有参数但不是来自的参数的程序文本文件。 这是我所做的,但似乎不起作用!

private void btnStart_Click(object sender, RoutedEventArgs e)
    {
        ProcessStartInfo startInfo = new ProcessStartInfo(string.Concat("RustClient.exe"));
        startInfo.Arguments = @"Resources\arguments.txt";
        startInfo.UseShellExecute = false;
        System.Diagnostics.Process.Start(startInfo);
    }

它启动了程序,但没有我在 txt 文件中输入的参数。

如果我想从 TXT 中阅读它们是因为我希望它们是可编辑的。基本上,我的程序将是一种为不了解它们的人编辑启动选项的简单方法

我在编码方面非常非常菜鸟,这是我的第一个编码项目,我必须 google 一切 ^^

先从文件中读取参数文本,然后将其分配给参数

private void btnStart_Click(object sender, RoutedEventArgs e)
    {
        string arg = File.ReadAllText("text file location");
        ProcessStartInfo startInfo = new ProcessStartInfo(string.Concat("RustClient.exe"));
        startInfo.Arguments = arg;
        startInfo.UseShellExecute = false;
        System.Diagnostics.Process.Start(startInfo);
    }