我在How can I read multiple text files and store them in a TextBox?上看到了一个类似的问题,但它对我正在尝试做的事情没有任何帮助。我正在尝试将多个富文本文件加载到1个富文本框中,这可能吗?我目前的代码是:
Private Sub LoadButton_Click(sender As Object, e As EventArgs) Handles LoadButton.Click
Dim openFile1 As New OpenFileDialog()
openFile1.DefaultExt = "*.rtf"
openFile1.Filter = "RTF Files|*.rtf"
Dim openFile2 As New OpenFileDialog()
openFile2.DefaultExt = "*.rtf"
openFile2.Filter = "RTF Files|*.rtf"
If (openFile1.ShowDialog() = System.Windows.Forms.DialogResult.OK) And
(openFile2.ShowDialog() = System.Windows.Forms.DialogResult.OK) Then
RichTextBox1.LoadFile(openFile1.FileName, openFile2.FileName)
End If
End Sub
将一个文件加载到文本框没有问题,但如果我尝试使用第一个文件添加第二个文件,则会崩溃。
我得到的当前错误是“从字符串转换”C:\ Software Development \ Test \ ann“to type'Engger'无效。”
C:\ Software Development \ Test \ ann是openFile2.FileName