calling a ruby script in c#

后端 未结 2 1740
-上瘾入骨i
-上瘾入骨i 2020-12-11 09:07

How do make a call to a ruby script and pass some parameters and once the script is finished return the control back to the c# code with the result?

2条回答
  •  误落风尘
    2020-12-11 09:56

        void runScript()
        {
            using (Process p = new Process())
            {
                ProcessStartInfo info = new ProcessStartInfo("ruby C:\rubyscript.rb");
                info.Arguments = "args"; // set args
                info.RedirectStandardInput = true;
                info.RedirectStandardOutput = true;
                info.UseShellExecute = false;
                p.StartInfo = info;
                p.Start();
                string output = p.StandardOutput.ReadToEnd();
                // process output
            }
        }
    

提交回复
热议问题