使用参数在c#中运行linux可执行文件

使用参数在c#中运行linux可执行文件,c#,linux,parameters,executable,C#,Linux,Parameters,Executable,我需要在没有扩展名的情况下运行一个linux文件,并在c#中使用运行时参数,我想知道您是否可以使用某些函数直接执行此操作,或者您需要用代码编写运行时bash脚本 例如: 运行c:/app-port=(在代码中更改端口变量)这是一种典型的方法,可以使用参数启动终端应用程序,等待它完成,然后输出它发送给stdout的内容 using(var p = Process.Start(new ProcessStartInfo { FileName = "/bin/ls", //

我需要在没有扩展名的情况下运行一个linux文件,并在c#中使用运行时参数,我想知道您是否可以使用某些函数直接执行此操作,或者您需要用代码编写运行时bash脚本

例如:


运行c:/app-port=(在代码中更改端口变量)

这是一种典型的方法,可以使用参数启动终端应用程序,等待它完成,然后输出它发送给stdout的内容

using(var p = Process.Start(new ProcessStartInfo
{
    FileName = "/bin/ls", // File to execute
    Arguments = "~/Documents", // arguments to use
    UseShellExecute = false, // use process creation semantics
    RedirectStandardOutput = true, // redirect standard output to this Process object
    CreateNoWindow = true, // if this is a terminal app, don't show it
    WindowStyle = ProcessWindowStyle.Hidden // if this is a terminal app, don't show it
})
{
    // Wait for the process to finish executing
    p.WaitForExit();
    // display what the process output
    Console.WriteLine(p.StandardOutput.ReadToEnd());
}

查看
System.Diagnostics.Process
以及如何准确运行该进程?既然您使用的是Linux,那么您是否使用.NET内核和Mono?我想这没关系。我将写一个例子。所以对于我的例子,我将使用“/home/program”作为文件名,-port=777”作为参数?这是正确的语法吗?@fesdfadfa--是的,这就是你应该做的。我试过了,它只是说Native error=找不到指定的文件。我确保文件确实存在,我仍然对无扩展名的文件感到困惑,也许这不是执行它们的正确方法?我的输入:ApplicationName='/home/ubuntu/.steam/SteamApps/common/'Retail Royale Server'/LinuxServer/IkeaBR_Server/Binaries/Linux/IkeaBR_ServerServer',CommandLine='-log-queryport=27020-port=7780',CurrentDirectory=''btw通过终端运行此文件,带有./IkeaBR_serverworks