Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从C运行Git时出现问题_C#_Git - Fatal编程技术网

C# 从C运行Git时出现问题

C# 从C运行Git时出现问题,c#,git,C#,Git,我试图使用System.Diagnostics.Process从C程序运行一些Git命令,但它不起作用。Git在我的路径中,当我尝试在命令提示符下运行命令时,它工作正常。我尝试过使用嵌套的using语句捕获标准输出,但没有帮助。当它到达reader.ReadToEnd时,它只显示DOS窗口,其中没有任何内容。这是我的密码: System.Diagnostics.Process process = new System.Diagnostics.Process(); System.Diagnosti

我试图使用System.Diagnostics.Process从C程序运行一些Git命令,但它不起作用。Git在我的路径中,当我尝试在命令提示符下运行命令时,它工作正常。我尝试过使用嵌套的using语句捕获标准输出,但没有帮助。当它到达reader.ReadToEnd时,它只显示DOS窗口,其中没有任何内容。这是我的密码:

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.UseShellExecute = false;
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
startInfo.WorkingDirectory = "c:\\gitmover";
startInfo.FileName = "cmd.exe";
startInfo.Arguments = " git add \"*.*\"";
using (Process process = Process.Start(startInfo))
{
      using (StreamReader reader = process3.StandardOutput)
      {
          string result = reader.ReadToEnd();
      }
}

你知道我可能做错了什么吗?

git exe在你的路径上吗?windows cmd.exe和git bash并不总是共享路径。例如,前几天我被windows/mingw'echo'命令之间的差异所困扰->是-git.exe肯定在我的路径中。正如我所说,当我在命令提示符下运行该命令时,它运行正常。git是否在您的c:\gitmover目录中?听起来您可能遇到了这个问题:我看了那篇文章,但那里似乎没有适合我的解决方案。我尝试了process.StandardOutput.Peek>-1,但在读了三行之后它仍然挂起。