How to save the XML log
This VB code will close a WinSCP session, saving the XML log to xmlSavePath
Imports System.IO
Imports System.Reflection
Sub EndWinScpSession(ByVal ftpSession As WinSCP.Session, ByVal xmlSavePath As String)
'Close the WinSCP session, saving the XML log file to xmlSavePath
Dim piXmlLogPath As PropertyInfo = GetType(WinSCP.Session).GetProperty("XmlLogPath", BindingFlags.NonPublic Or BindingFlags.Instance)
Dim xmlLogPath As String = piXmlLogPath.GetValue(ftpSession, Nothing)
piXmlLogPath.SetValue(ftpSession, Nothing, Nothing) 'this prevents the xml log being deleted by WinSCP
ftpSession.Dispose() 'this is necessary to complete the XML log
'copy the xml log where we want it and then delete the original
Dim fi As New FileInfo(xmlLogPath)
fi.CopyTo(xmlSavePath, True)
fi.Delete()
End Sub