且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我怎么可以在C#控制台应用程序执行CMD命令?

更新时间:2023-02-19 20:00:15

还有一个原因,为什么你不叫mysqldump的直接?

Is there a reason why you don't call mysqldump directly?

ProcessStartInfo procStartInfo = 
    new ProcessStartInfo("mysqldump", "uroot ppassword databse > c:/data.sql");

如果没有的是的一个原因,你的code应该是这样的:

If there is a reason, your code should look like this:

ProcessStartInfo procStartInfo = 
    new ProcessStartInfo("cmd", 
        "/c \"mysqldump uroot ppassword databse > c:/data.sql\"");

更改:

  • 您在哪里失踪的 CMD 变量mysqldump的。
  • 您应该把命令,在命令行中执行到引号。
  • You where missing "mysqldump" in your cmd variable.
  • You should put the command to be executed in the command line into quotes.