Hello, I confirm that I am still not able to solve my issue below.
Thanks. -----Original Message----- From: TWSocket [mailto:twsocket-boun...@lists.elists.org] On Behalf Of Ertan Küçükoğlu Sent: Thursday, July 21, 2016 7:53 PM To: twsocket@lists.elists.org Subject: [twsocket] TFtpClient - listing filenames using stream Hi, I am not quite sure as to what version of ICS I have. I read V8.23 somewhere in “svn-changelog-icsv8.txt” file, and TFtpClient.FtpClientID is “ICS FTP Client V8.09”. In one of my projects I did use TIdFTP for downloading some files. Project is finished, and running now. Recently, it’s blocking operation type of working started to be a poblem. I am checking TFtpClient samples as to how can I do the switch for non-blocking ftp downloads. So far I believe, I can use TFtpClient to download a file which I know it’s name and full URL. Though; 1- I do need some help to list files in the FTP server I am connecting. I want to use LocalStream (Please see below) 2- It’s maybe me, but I couldn’t find any sample as to listing of files in a directory using wildcards and excluding directories (or some how identifying them). Currently, I do not know if I can or how to pass this wildcard to the file listing in order to get only the relevant files listed. My current code is: procedure TForm10.FtpClient1RequestDone(Sender: TObject; RqType: TFtpRequest; ErrCode: Word); var TempString: string; begin Memo1.Lines.Add(FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', now) + ' On request:' + IntToStr(Ord(RqType))); if ErrCode <> 0 then begin Memo1.Lines.Add(FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', now) + ' *** ERROR: ' + FtpClient1.ErrorMessage); if RqType <> ftpOpenAsync then FtpClient1.QuitAsync; Exit(); end; case RqType of ftpOpenAsync: FtpClient1.UserAsync(); ftpUserAsync: FtpClient1.PassAsync(); ftpPassAsync: FtpClient1.CwdAsync(); ftpCwdAsync: begin FtpClient1.HostFileName := EmptyStr; FtpClient1.LocalFileName := EmptyStr; FtpClient1.LocalStream := TMemoryStream.Create(); FtpClient1.LsAsync(); end; ftpLsAsync: begin // FtpClient1.LocalStream.Position := 0; // Using only these 3 lines also giving me similar result // SetLength(TempString, FtpClient1.LocalStream.Size); // CopyMemory(Pointer(TempString), TMemoryStream(FtpClient1.LocalStream).Memory, FtpClient1.LocalStream.Size); SetString(TempString, PChar(TMemoryStream(FtpClient1.LocalStream).Memory), FtpClient1.LocalStream.Size div SizeOf(Char)); Memo1.Lines.Add('-----'); Memo1.Lines.Add(TempString); Memo1.Lines.Add('-----'); FtpClient1.TypeSetAsync(); end; ftpTypeSetAsync: begin FtpClient1.HostFileName := 'abcdef.txt'; FtpClient1.LocalFileName := edtLocalPath.Text + '\' + FtpClient1.HostFileName; FtpClient1.GetAsync; end; ftpGetAsync: begin FStatus := FtpClient1.StatusCode = 226; FtpClient1.QuitAsync; end; ftpQuitAsync: if FStatus then Memo1.Lines.Add('File Download OK'); else Memo1.Lines.Add('Unknown RqType: ' + IntToStr(Ord(RqType))); end; end; Part of what I get in Memo is something like below: ===== Beginning ===== 2016-06-22 04:12:01.784 On request:4 2016-06-22 04:12:01.787 > PASV 2016-06-22 04:12:01.938 < 227 Entering Passive Mode (5,229,203,64,227,54). 2016-06-22 04:12:01.953 > NLST 2016-06-22 04:12:02.188 < 150 Opening data connection for (N/A) (*hidden*). 2016-06-22 04:12:02.338 < 226 Closing data connection. File: N/A 2016-06-22 04:12:02.340 ! 167bytes received/sent in 297 milliseconds 2016-06-22 04:12:02.342 On request:8 ----- മ⸊മ匊偍〰䈮义〲㔱〱䵓ぐ〰⸱千ൖ㈊ㄵറ㈊ㄵല㈊㠰വ㈊〶റ㈊〶ല㈊㠰ശ匊ㅋ⹁千ൖ㈊〶ള㈊〶ഴ匊偍〰㈰䈮义䵓ぐ〰⸲千ൖ匊㉋⹁千ൖ㈊〶വ㈊〶ശ ----- 2016-06-22 04:12:02.361 > TYPE I 2016-06-22 04:12:02.455 < 200 Command okay. ===== END ===== Thanks. Regards, Ertan Küçükoğlu -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be