Tag: console application

从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"); 但没有发生。 运行我的应用程序后,我只有2个空行。 请帮忙解决这个问题。