Advertisement
drkbl

Display log in a multiline textbox reverse order

Jul 21st, 2024
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.79 KB | Source Code | 0 0
  1. With My.Application.Log.DefaultFileLogWriter
  2.   .Flush()
  3.   My.Forms.FormLog.LogTextFromFile = .FullLogFileName
  4. End With
  5. My.Forms.FormLog.ShowDialog()
  6.  
  7. Public WriteOnly Property LogTextFromFile() As String
  8.   Set(ByVal value As String)
  9.     Dim _text As String = ""
  10.     Using _stream As FileStream = File.Open(value, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
  11.       Dim _buffer As Byte() = New Byte(_stream.Length) {}
  12.       Dim _encoding As UTF8Encoding = New UTF8Encoding(True, True)
  13.       Do While _stream.Read(_buffer, 0, _buffer.Length) > 0
  14.         _text = _text + _encoding.GetString(_buffer)
  15.       Loop
  16.     End Using
  17.     Dim _lines = Strings.Split(_text, vbCrLf)
  18.     Array.Reverse(_lines)
  19.     TLog.Text = Join(_lines, vbCrLf).Replace(vbNullChar, "*")
  20.   End Set
  21. End Property
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement