+1 vote


does anyone knows the source in vb.net about to append the content of a richttextbox due to the last Log-Messages like Limilabs.FTP.Log.WriteLine +?


1 Answer

0 votes

I'm not sure what your problem is, Log.WriteLine is a simple event, that allows you to hookup your logging mechanism into Ftp.dll.

You simply subscribe to this event and do whatever you want with the string message, that is reported every time Ftp.dll logs an event.

Here's an example of a static Logger class that gathers all logs:

Public Class Logger
    Dim Shared ReadOnly _logger = New StringBuilder()

    Public Shared Sub AppendLine(line As String)
    End Sub

    Public Shared Function GetLog() As String
        GetLog = _logger.ToString()
    End Function
End Class

Here's the code that 'registers' it in Ftp.dll:

Log.Enabled = True
AddHandler Log.WriteLine, Sub(x) Logger.AppendLine($"Log: {x}")

Somewhere on the form load:

TextBox1.Text = Logger.GetLog()
by (295k points)