运行 linux 可在 c# 中使用参数执行
run linux executable in c# with params
我需要 运行 一个没有扩展名的 linux 文件,在 c# 中带有 运行time 参数,我想知道您是否可以直接使用某些函数或您需要在代码中编写 运行time bash 脚本。
示例:
运行 c:/app -port=(在代码中更改端口变量)
这是启动带参数的终端应用程序的典型方法,等待它完成,然后输出它发送到标准输出的内容。
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());
}
我需要 运行 一个没有扩展名的 linux 文件,在 c# 中带有 运行time 参数,我想知道您是否可以直接使用某些函数或您需要在代码中编写 运行time bash 脚本。
示例:
运行 c:/app -port=(在代码中更改端口变量)
这是启动带参数的终端应用程序的典型方法,等待它完成,然后输出它发送到标准输出的内容。
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());
}