VB.NET怎么读取.DOC文件的。我怎么读出来都是乱码

来源:百度知道 编辑:UC知道 时间:2024/06/19 17:08:03
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If File.Exists("c:\aa.txt") = False Then
MsgBox("文件不存在!")
Else
Dim sr As StreamReader = File.OpenText("c:\aa.txt")
Dim str As String = sr.ReadLine
Dim i As Integer = 0
While Not IsNothing(str)
i = i + 1
If i = 1 Then
Me.TextBox1.Text &= str
Else
Me.TextBox1.Text &= "," + str
End If

str = sr.ReadLine
End While
End If
End Sub
End Class

现在只能读取TXT的 但我想读取.DOC 我该怎么办

编码没有处理好,
Dim sr As StreamReader = File.OpenText("c:\aa.doc",default.code)
后面还有一个参数,具体我忘记了,你上网查一下

楼上的,即死

doc是二进制文件,怎么可能用opentext读?

这样,可以调用Word的相应模块来读取,不过读出来也是word文档
你要干什么?