drkbl icon

Display log in a multiline textbox reverse order

drkbl | PRO | 07/21/24 04:44:00 PM UTC | 0 ⭐ | 7302 👁️ | Never ⏰ | [VB.NET, my.application.log]
VB.NET |

790 B

|

Source Code

|

0 👍

/

0 👎

With My.Application.Log.DefaultFileLogWriter
  .Flush()
  My.Forms.FormLog.LogTextFromFile = .FullLogFileName
End With
My.Forms.FormLog.ShowDialog()
 
Public WriteOnly Property LogTextFromFile() As String
  Set(ByVal value As String)
    Dim _text As String = ""
    Using _stream As FileStream = File.Open(value, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
      Dim _buffer As Byte() = New Byte(_stream.Length) {}
      Dim _encoding As UTF8Encoding = New UTF8Encoding(True, True)
      Do While _stream.Read(_buffer, 0, _buffer.Length) > 0
        _text = _text + _encoding.GetString(_buffer)
      Loop
    End Using
    Dim _lines = Strings.Split(_text, vbCrLf)
    Array.Reverse(_lines)
    TLog.Text = Join(_lines, vbCrLf).Replace(vbNullChar, "*")
  End Set
End Property

Comments