Page 1 of 1

sftp ReadDirectory

Posted: Tue 26 Jun 2018 13:44
by vorosg
Hello,
can anyone help me, what would be the problem: there's a procedure (Delphi, XE2) based on a demo, to read a remote directory from a server. When it runs first time, it reads succesfully. But any other occasions, after SFTP.OpenDirectory() gave back a handle, the SFTP client's EOF remains TRUE, so SFTP.ReadDirectory(Hdl) inside of the while-cycle won't be executed. I don't understand why.
(this procedure worked well with the 60 days trial version)
Has anyone any idea?

thanks,
Gábor
//------------------------------
procedure TForm1.ReadDir;
var n,i:integer;
Hdl:tScSFTPFileHandle; apUPLMAP:String;
begin
Hdl := SFTP.OpenDirectory(apUPLMAP);
try
while not SFTP.EOF do begin
SFTP.ReadDirectory(Hdl);
end;
finally
SFTP.CloseHandle(Hdl);
end;
end;
//---------------------------

Re: sftp ReadDirectory

Posted: Tue 26 Jun 2018 13:52
by ViktorV
To solve your task, you should use the following code:

Code: Select all

repeat
SFTP.ReadDirectory(Hdl); 
until SFTP.EOF;
вместо

Code: Select all

while not SFTP.EOF do begin
SFTP.ReadDirectory(Hdl); 
end; 

Re: sftp ReadDirectory

Posted: Tue 26 Jun 2018 14:17
by vorosg
This question has cancelled, Viktor (Devart Team) solved it very soon.
Here we should use a repeat-until-cycle instead of a while-cycle.
That's all.
Thanks to him!

Re: sftp ReadDirectory

Posted: Tue 26 Jun 2018 14:49
by ViktorV
It is good to see that the problem has been solved.
Feel free to contact us if you have any further questions about our products.