How to limit record count while fetching data to sftpitemcollection via Rebex?

0 votes
asked Feb 13 by alexander.junior (380 points)
reopened Mar 7 by Lukas Pokorny

Currently I am fetching all the files from the folder configured after connection to sftp.If the count of files is very large(say 800000 files or so) time out is happening. We want to limit the number of files to be fetched. We are currently fetching the files as below:

            SftpItemCollection list = dSftp.GetList(strServerPath + "//" + "*." + extension);

            foreach (SftpItem item in list)
            {
                dtOutput.Rows.Add(strFileType, item.Name);////, item.Size.ToString(), item.Modified.ToString("dd/MM/yyyy HH:mm:ss"));

            }
Applies to: Rebex SFTP
commented Feb 14 by alexander.junior (380 points)
Is it possible to fetch 100 records alone out of the (say  8 lakh records ) via sftp Rebex. Please provide a solution asap

1 Answer

0 votes
answered Mar 7 by Lukas Pokorny (94,310 points)

You can fetch files continuously in small chunks from the beginning of the directory using Sftp.ListItemReceived event handler.
To finish fetching when you find specific file (or when the desired number of files has been fetched), call Sftp.Abort method.

However, please note that the SFTP protocol doesn't support directory listing paging (it always starts at the beginning).

...