SynchronizationMode Local with FileMask

Advertisement

GerGer
Joined:
Posts:
1
Location:
philipines

SynchronizationMode Local with FileMask

HI i'am trying to automate sync. process of my local directory for .txt file only. but i'm having this error when trying to used the TransferOptions. help me pls.

WinSCP.Session.SynchronizeDirectories(WinSCP.SynchronizationMode, string, string, bool, bool, WinSCP.SynchronizationCriteria, WinSCP.TransferOptions)' has some invalid arguments
private void buttonReportsData_Click(object sender, EventArgs e)
{
    label1.Visible = true;
 
    try
    {
        // Setup session options
        SessionOptions sessionOptions = new SessionOptions
        {
            Protocol = Protocol.Ftp,
            HostName = "000.000.0.00",
            UserName = "HomeBoy",
            Password = "1234567",
        };
 
        using (Session session = new Session())
        {                  
            
            // Will continuously report progress of synchronization
            //session.FileTransferred += FileTransferred;
 
            // Connect
            session.Open(sessionOptions);
 
            while (true)
            {
                //string filemask = "*.txt";
 
                buttonReportsData.BackColor = Color.DarkSeaGreen;
                buttonReportsData.Text = "Sync-Started";
                label1.Text = "FTP Sync process Started";
 
                TransferOptions transOp = new TransferOptions();
                transOp.FileMask = "*.txt";
                transOp.TransferMode = TransferMode.Automatic;
 
                // Synchronize files
                SynchronizationResult synchronizationResult;
                synchronizationResult =
                    session.SynchronizeDirectories(
                        SynchronizationMode.Local, @"C:\temp", "/folder1", false, transOp);
 
                // Throw on any error
                synchronizationResult.Check();
            }
        }
    }
    ...
}

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
35,438
Location:
Prague, Czechia

Re: SynchronizationMode Local with FileMask

The TransferOptions are 7th argument of Session.SynchronizeDirectories, not 5th.
https://winscp.net/eng/docs/library_session_synchronizedirectories

You either need to specific 5th and 6th arguments:
session.SynchronizeDirectories(
    SynchronizationMode.Local, @"C:\temp", "/folder1", false,
    false, SynchronizationCriteria.Time, transOp);
or use a named argument:
session.SynchronizeDirectories(
    SynchronizationMode.Local, @"C:\temp", "/folder1", false,
    options = transOp);

Reply with quote

Advertisement

You can post new topics in this forum