简体   繁体   English

C#,Powershell和控制台应用程序-如何在处理过程中处理输入

[英]C#, Powershell and console applications - How to handle input during processing

Part of a program that I am creating for myself allows for PowerShell commands and scripts to be run from within the program (no need to open a PowerShell cli because it is already there). 我为自己创建的程序的一部分允许在程序内运行PowerShell命令和脚本(无需打开PowerShell cli,因为它已经存在)。 For the most part, things work great, I can type in and execute commands and scripts just fine, but if it requires input before the command/script/program is done executing, it fails. 在大多数情况下,一切工作正常,我可以键入并执行命令和脚本,但是如果在执行命令/脚本/程序之前需要输入,则它将失败。 What I am currently trying to get working is ftp and I am at a loss. 我目前想开始工作的是ftp,我很茫然。 If anyone knows how to get ftp (or similar programs) running through a C# runspace or any resources that explain it, I would be grateful. 如果有人知道如何通过C#运行空间或解释它的任何资源来运行ftp(或类似程序),我将不胜感激。

You will need to redirect the console IO streams. 您将需要重定向控制台IO流。

See MSDN entry Process.BeginOutputReadLine for an example of how to get started. 有关如何开始的示例,请参见MSDN条目Process.BeginOutputReadLine

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM