0 votes
by (600 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
by (73.5k 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/*.*");
...