在C#中运行命令不提供任何输出

时间:2018-04-24 11:19:59

标签: c#

当我从命令提示符运行relog命令时,我没有任何问题地获得输出。

enter image description here

现在,当我尝试使用C#代码运行命令时,我没有得到任何输出。可能是什么问题?

public static string Bash()
    {
        var process = new Process()
        {
            StartInfo = new ProcessStartInfo
            {
                FileName = "cmd.exe",
                WorkingDirectory = @"C:\blgs",
                Arguments = "relog.exe sample.blg",
                RedirectStandardOutput = true,
                UseShellExecute = false,
                CreateNoWindow = true,
            }
        };
        process.Start();
        string result = process.StandardOutput.ReadToEnd();
        process.WaitForExit();
        return result;
    }

0 个答案:

没有答案