0 votes
by (560 points)
reopened by

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
by (560 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
by (145k 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).