c# - 为什么我使用 textBox1.AppendText 时文本框中没有出现换行符
问题描述
我一直在尝试在 c# 中使用 ssh.net libray 制作某种终端应用程序。我已成功发送命令并接收输出,但是当我将输出附加到文本框时,新行字符消失了,尽管我可以在消息框中看到它们。我该如何解决这个问题?
SshCommand sc = client.CreateCommand(command);
sc.Execute();
textBox1.AppendText(command);
textBox1.AppendText("\n");
string answer = sc.Result;
textBox1.AppendText(answer);
MessageBox.Show(sc.Result);
textBox1.AppendText("\n");
textBox2.Clear();
当我运行 ls 命令时,我得到的输出为:
解决方案
问题是您使用TextBox
which 不适用\n
,它需要\r\n
作为新行。
您可以使用RichTextBox
which 仅适用于 a\n
作为换行符。
推荐阅读
- sql-server - Connection with MSSQL
- c# - 如何在 ASP.NET Core MVC 中获得单击按钮的值?
- substrate - 在基材墨水上!如何获取调试信息?
- javascript - useEffect 首次打破 useState 数组
- php - Insert given string value in mysql database as datetime with php
- ubuntu - Emscripten package on Ubuntu 16.04. How to get it to work?
- javascript - Determine the average value across a range of data
- html - 无法在 HTML/CSS 中定位按钮
- r - 如何在现有的相关矩阵上运行 PCA,然后运行回归?
- javascript - 在浏览器和 NodeJS 中加载 JSON 文件的单一 API?