How to get some files after fetching files via SFTPItemcollection c#?

0 votes
asked Feb 14 by alexander.junior (380 points)

I want to get 1000 files out of 5 lakh records or so after fetching files via SFTPItemcollection in c#

SftpItemCollection list = dSftp.GetList();

            foreach (SftpItem item in list)
            {
                dtOutput.Rows.Add(strFileType, item.Name);////, item.Size.ToString(), item.Modified.ToString("dd/MM/yyyy HH:mm:ss"));
                WriteLog("strFiletype:" + strFileType + "   " + "filename" + item.Name + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss:fff"));
            }
Applies to: Rebex SFTP

1 Answer

0 votes
answered Feb 14 by Lukas Matyska (44,590 points)

You can fetch files on the fly like this:

client.ListItemReceived += (s, e) =>
{
    dtOutput.Rows.Add(e.Item.Type, e.Item.Name);

    if (dtOutput.Rows.Count >= 10)
        client.AbortTransfer();
};

client.GetList(@"/home/tester/*.*");
...