XML Logging

Advertisement

GTSageDev
Joined:
Posts:
7
Location:
United Kingdom

XML Logging

If possible, I'd like to retain the WinSCP XML log, preferably not in %TEMP%. Is there a way of configuring WinSCP.Session to use a specific XMLLog path and not delete it when the session is disposed?

Apologies if this has been asked before - I have looked! I realise this may not be simple, as the assembly uses the XML log to see what's going on in WinsSCP.

Thanks for a really useful bit of software; I wish I had found it earlier - System.Net.FtpWebRequest does have its limitations!

Using WinScp.dll v1.0.2.2735

Reply with quote

Advertisement

GTSageDev
Joined:
Posts:
7
Location:
United Kingdom

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

Reply with quote

Advertisement

You can post new topics in this forum