【问题标题】:call exe program in C#在C#中调用exe程序
【发布时间】:2011-02-19 11:06:20
【问题描述】:

如何调用从一个 c# 文件生成的 exe,从另一个 c# 文件?

【问题讨论】:

标签: c#


【解决方案1】:

如果要在执行前生成C#文件,可以使用CSharpCodeProvider编译C#文件,然后使用Process class执行输出文件。

您可以在提供的链接中找到每个示例。

【讨论】:

    【解决方案2】:
    using System.Diagnostics;
    
    string command = @"C:\tmp\myExe.exe -my -params";
    
    ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + command)
        {
            RedirectStandardOutput = true,
            UseShellExecute = false,
            CreateNoWindow = true
        };
    
    using (Process proc = new Process())
    {
        proc.StartInfo = procStartInfo;
        proc.Start();
    
        return proc.StandardOutput.ReadToEnd();
    }
    

    【讨论】:

      【解决方案3】:

      System.Diagnostics.Process.Start("Path to any file, including exes");

      【讨论】:

        猜你喜欢
        • 2015-09-21
        • 2015-02-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-05
        • 1970-01-01
        相关资源
        最近更新 更多