【发布时间】:2010-05-01 14:23:56
【问题描述】:
我正在尝试将文件加载到 Windows froms(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 或 word pad 中创建的 rtf 文件,并尝试将 .cs 文件另存为 .rtf,但没有成功。
请提供任何帮助。
【问题讨论】:
-
使用真正的 RTF 文件。使用写字板或 Microsoft Word 创建一个。
-
运气好吗?我一直想知道你是否发现了这个问题。
标签: c# windows richtextbox