grabbing the subdirectories that are 5 minutes old

Advertisement

anjali
Joined:
Posts:
3
Location:
anjali

grabbing the subdirectories that are 5 minutes old

Hello All,

I want to SFTP files and sub folders from my local path to remote path. My code is working fine if I want to transfer all the files and sub directories, but I only want to grab those sub directories that are 5 minutes old. In other words, I dont want to grab any sub directory that is very new. How can I achieve this. Below is my code:

TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
 
TransferOperationResult transferResult;
transferResult =
    session.PutFiles(@"K:\Documents\*", "/D:/Files/"true, transferOptions);
 
// Throw on any error
transferResult.Check();

Any Help will be greatly appreciated.

Reply with quote

Advertisement

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

Re: grabbing the subdirectories that are 5 minutes old

WinSCP cannot select folders based on a time, only files. Can you use the timestamps of contained files for the selection?

Reply with quote

anjali
Joined:
Posts:
3
Location:
anjali

Re: grabbing the subdirectories that are 5 minutes old

Yes, I can. How do I filter out the files that are 5 minutes old. I tried to use this mask, but it doesnt work:
transferOptions.FileMask = "*<=10N";
Below is my full code in C#:
string localPath = ConfigurationManager.AppSettings["localPath"];
string remotePath = ConfigurationManager.AppSettings["remotePath"];
using (Session session = new Session())
{
    // Connect
    session.Open(sessionOptions);
 
    // Download files
    TransferOptions transferOptions = new TransferOptions();
    transferOptions.TransferMode = TransferMode.Binary;
    transferOptions.FileMask = "*<=10N";
    TransferOperationResult transferResult;
    transferResult =
        session.PutFiles(@"K:\*", "/D:/eFiles/"true, transferOptions);
 
    // Throw on any error
    transferResult.Check();
 
    // Print results
    foreach (TransferEventArgs transfer in transferResult.Transfers)
    {
        Console.WriteLine("Download of {0} succeeded", transfer.FileName);
    }
}

any help will be highly appreciated.

Reply with quote

martin
Site Admin
martin avatar

Re: grabbing the subdirectories that are 5 minutes old

So what does it do when "it doesn't work"? Consider posting a session log file, if appropriate, to document the problem.

Reply with quote

Advertisement

You cannot post new topics in this forum