Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Tracking which files are being added during sync

jpmcfeely wrote:

I am using the SynchronizeDirectories method as shown in the code below. My question is there any way of tracking which files are added to the local directory so that it can be written to a log file?

The easiest way is to iterate SynchronizationResult.Downloads returned by Session.SynchronizeDirectories.
https://winscp.net/eng/docs/library_session_synchronizedirectories
https://winscp.net/eng/docs/library_synchronizationresult

I have added the FileTransferred method in the example here:
https://winscp.net/eng/docs/library_session_synchronizedirectories#reallife

It should be triggered. Show us the code that you have tried.
jpmcfeely

Tracking which files are being added during sync

I am using the SynchronizeDirectories method as shown in the code below. My question is there any way of tracking which files are added to the local directory so that it can be written to a log file?

My code is as follows:
SessionOptions sessionOptionsROI = new SessionOptions
{
Protocol = Protocol.Ftp,
FtpMode = FtpMode.Passive,
FtpSecure = FtpSecure.Explicit,
HostName = ConfigurationManager.AppSettings["HostName"].ToString(),
UserName = ConfigurationManager.AppSettings["ROIUsername"].ToString(),
Password = ConfigurationManager.AppSettings["ROIPassword"].ToString(),
};

using (Session sessionROI = new Session())
{
// Connect
sessionROI.Open(sessionOptionsROI);

sessionROI.SynchronizeDirectories(SynchronizationMode.Local, @"\\10.176.1.8\Project\Company\FTP\ROI\REPORTS\", "/REPORTS", false, false, SynchronizationCriteria.Time, null).Check();
}

I have added the FileTransferred method in the example here:
https://winscp.net/eng/docs/library_session_synchronizedirectories#reallife

But this method is never triggered