本来想读个文件,但却整死也读不出来!

lxstruggle 2005-04-19 11:57:10
代码如下:

Dim fr As New StreamReader(filestr, System.Text.Encoding.Default)

Dim str As String
Dim strwrite As String

Do
str = fr.ReadLine
str = str.Substring(0, str.IndexOf("'"))
strwrite = strwrite + str

Loop Until str Is Nothing

如果后缀为“.txt”就可以读出来,但我现在读的是".vb"文件,用记事本都可以打开啊,杂个readline就为空呢
...全文
111 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xxuu503 2005-04-19
  • 打赏
  • 举报
回复
str = fr.ReadLine//Readtoend看看,看看能不能读出来
rock29 2005-04-19
  • 打赏
  • 举报
回复
Imports System
Imports System.IO

Class Test
Public Shared Sub Main()
Try
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New StreamReader("TestFile.txt")
Dim line As String
' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()
Console.WriteLine(Line)
Loop Until line Is Nothing
sr.Close()
Catch E As Exception
' Let the user know what went wrong.
Console.WriteLine("The file could not be read:")
Console.WriteLine(E.Message)
End Try
End Sub
End Class

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧