【发布时间】:2019-06-11 21:42:39
【问题描述】:
我找不到任何示例,也无法确定如何将行从文本框发送到数组并单独用作 cmd.exe 参数的一部分。
我可以处理一行,但是当我尝试实现数组时,我被挂断了。
private void Button1_Click(object sender, EventArgs e)
{
var Textbox1Var = Textbox1.Text;
string[] Textbox2Var = Textbox1.Text.Split('\n');
void RunCmd()
{
Process.Start("cmd.exe", @"/k [command] parameter1 " +
Textbox1Var + " " + Textbox2Var).WaitForExit();
//I know this isn't right and I probably need a foreach somewhere
//That's wht I need help with.
//This is the current stored code but have made multiple attempts
}
RunCmd();
}
我希望该过程完成并在用户按 Enter 键关闭提示时显示响应,但目前我的代码中只有错误或循环问题...
【问题讨论】:
-
我不明白这与我的用例有什么关系,但假设调用 cmd.exe 只是为了让命令框不消失以便可以查看结果。你将做点什么不同的?描述了我的用例:我希望完成该过程并在用户按 Enter 键关闭提示时显示响应。
-
主要问题是数组。我可以在没有 cmd.exe 的情况下调用命令
标签: c# arrays process textbox multiline