sftp ReadDirectory

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
vorosg
Posts: 2
Joined: Tue 26 Jun 2018 10:32

sftp ReadDirectory

Post by vorosg » Tue 26 Jun 2018 13:44

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;
//---------------------------

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: sftp ReadDirectory

Post by ViktorV » Tue 26 Jun 2018 13:52

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; 

vorosg
Posts: 2
Joined: Tue 26 Jun 2018 10:32

Re: sftp ReadDirectory

Post by vorosg » Tue 26 Jun 2018 14:17

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!

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: sftp ReadDirectory

Post by ViktorV » Tue 26 Jun 2018 14:49

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.

Post Reply