我正在尝试创建一个页面,让我从我正在监控的聊天室中读取日志文件...我正在努力让这个因某些原因而工作......我已经拿了一些东西和代码片段,以获得我的工作...但它仍然要么不显示或约200行后,它停止读取每一行,而是使它成为一大堆文本...这里是我的有代码
Protected Sub bView_Click(sender As Object, e As EventArgs) Handles bView.Click
Response.Write(Server.MapPath("~/mirc/logs/" & lbfiles.SelectedItem.Text))
lFileOut.Text = ""
Try
Dim FILENAME As String = Server.MapPath("~/mirc/logs/" & lbfiles.SelectedItem.Text)
Dim objStreamReader As StreamReader = New StreamReader(FILENAME, Encoding.UTF8)
Dim cont As String
Do
cont = objStreamReader.ReadLine()
lFileOut.Text = lFileOut.Text & cont & "<br>"
Loop Until cont Is Nothing
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
这是一个测试文件,我一直在测试所有内容......它只是没有做任何事情,也没有抛出任何错误...我完全被这个问题困扰。
请告诉我你知道任何有用的事情
答案 0 :(得分:0)
Protected Sub bView_Click(sender As Object, e As EventArgs) Handles bView.Click
Response.Write(Server.MapPath("~/mirc/logs/" & lbfiles.SelectedItem.Text))
lFileOut.Text = ""
Try
Dim FILENAME As String = Server.MapPath("~/mirc/logs/" & lbfiles.SelectedItem.Text)
Dim objStreamReader As StreamReader = New StreamReader(FILENAME, Encoding.UTF8)
Dim cont As String
cont = objStreamReader.ReadToEnd()
cont = cont.Replace(">", ">")
cont = cont.Replace("<", "<")
cont = cont.Replace(vbCrLf, "<br>")
cont = cont.Replace(vbLf, "<br>")
cont = cont.Replace(vbCr, "<br>")
lFileOut.Text = lFileOut.Text & cont & "<br>"
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
我想通了......用户名是,它认为这是一个HTML标签...时间:
> <