我正在尝试将文件加载到Windows Forms (VS 2010) richTextBox中,但只有文件的第一行被加载。 我使用的是:
// Create an OpenFileDialog to request a file to open.
OpenFileDialog openFile1 = new OpenFileDialog();
// Initialize the OpenFileDialog to look for RTF files.
openFile1.DefaultExt = "*.rtf";
openFile1.Filter = "RTF Files|*.rtf";
// Determine whether the user selected a file from the OpenFileDialog.
if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
// Load the contents of the file into the RichTextBox.
rtbTest.LoadFile(openFile1.FileName, RichTextBoxStreamType.PlainText);
}
我尝试使用在Word或WordPad中创建的RTF文件,也尝试将.cs文件另存为.rtf文件,但都没有成功。
如果有帮助,请提供支持,谢谢。