To solve your task, you should use the TScSFTPClient.OnDirectoryList event handler. For example:
Code: Select all
procedure TSFTPClientFrame.ScSFTPClientDirectoryList(Sender: TObject;
const Path: string; const Handle: TArray<System.Byte>;
FileInfo: TScSFTPFileInfo; EOF: Boolean);
begin
if (FileInfo = nil) or (FileInfo.Filename = '.') then
Exit;
if Pos('Jan', FileInfo.Filename) > 0 then
... save filename to list
end;
The OnDirectoryList event is raised on execution of the TScSFTPClient.ReadDirectory method.
The correct code for using the TScSFTPClient.ReadDirectory method is provided below:
Code: Select all
var
Handle: TScSFTPFileHandle;
...
oSFTPClient.SSHClient := oSSHClient;
oSFTPClient.Initialize;
Handle := oSFTPClient.OpenDirectory('\');
try
while not oSFTPClient.EOF do
oSFTPClient.ReadDirectory(Handle);
finally
oSFTPClient.CloseHandle(Handle);
end;
... download using list of filename