c# - 在我的应用程序中嵌入控制台应用程序

标签 c#

我有一个控制台应用程序,它启动另外两个控制台应用程序(不是用 C# 编写的)。

我可以将应用程序的输出定向到应用程序的同一个 CMD 窗口吗?

或者甚至只是禁止它们显示?

最佳答案

对这两个问题都是肯定的 - 您可以重定向输出并阻止它们显示。

看看ProcessStartInfo类 - 将其传递到 Process 的构造函数中类以确保它按照您想要的方式启动。

var psi = new ProcessStartInfo("path to exe to run");

// ensure output is redirected
// several options to read - using the StandardOutput stream of the process
//    another option is to hook up the OutputDataReceived event
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;


// ensure no window
psi.CreateNoWindow = true;
psi.WindowStyle = ProcessWindowStyle.Hidden; // requires UseShellExecute = false

关于c# - 在我的应用程序中嵌入控制台应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8771918/

相关文章:

c# - EF + 通用存储库 + 加载相关实体 : only explicit load works

c# - 使用 Lambda 表达式从字段名称中选择不同的字段

c# - donut 缓存 _Layout 与 mvcdonutcaching ASP.NET MVC

c# - 显示 div 以显示操作错误

c# - 在 Linq-To-Entities 中是否有替代 DateTime.Ticks 或 DateTime.TimeOfDay 的方法?

c# - 从代码隐藏填充 gridview

c# - Entity Framework 中唯一字段的选项 - dbSet 的导航属性?

c# - 如何验证此 ADFS token ?

c# - 单点触控 : About value types as Dictionary Keys

c# - 保持简单的成员资格 OAuth session 事件