我尝试从C#控制台应用程序运行“npm init”命令,使用以下代码:
我已经尝试使用以下代码从C#控制台应用程序运行“npm init”命令:
private void Execute(string command, string arg)
{
Process p = new Process();
p.StartInfo.FileName = command;
p.StartInfo.Arguments = arg;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.WorkingDirectory = @"E:\Work\";
p.Start();
p.WaitForExit();
}
Execute(@"C:\Program Files\nodejs\npm.cmd", "init");
但是什么都没有发生。在运行我的应用程序后,我只得到了两个空白行。请帮助解决这个问题。