FTPClient - Listing all files
Posted
#1
(In Topic #1321)
Regular

How can I put on a Listview all PDF files that exist in the FTP server using the FTPClient?
Posted
Guru

Just send a list command and process the results
What have you tried?
Do you know anything about sending FTP commands?
Basic FTP Commands
File Transfer Protocol (FTP), a List of FTP Commands
Use FtpClient.Exec() to send a command to list the directory and its _Read event for the results.
Do you know how to populate a ListView?
/comp/gb.qt4/listview/add - Gambas Documentation
if the ftp server has directory listing mode enabled (can be viewed in a browser) then possibly easier to simply use httpClient.Download() on the directory and process the page.
Posted
Regular

I'm struggling a lot to process the result and populate the control.
I'm going to go back to a tactic I've used before, creating a shell script to connect to the server, navigate to the desired directory and save the file names to a local text file.
Posted
Regular

Dim sLine As String
ListBox1.Clear
If Exist(Application.Path & "/arquivos") Then Kill Application.Path & "/arquivos"
Shell "curl –list-only ftp://" & user & ":" & pass & "@192.168.5.254 >" & Application.Path & "/arquivos"
Wait 2
hFile = Open Application.Path & "/arquivos" For Read
While Not Eof(hFile)
Line Input #hFile, sLine
If Right(sLine, 4) = ".pdf" Or Right(sLine, 4) = ".PDF" Then ListBox1.Add(sLine)
Wend
Close #hFile
1 guest and 0 members have just viewed this.


