How to list server/website files & folders and download selected file??

mdarkness

Member
Licensed User
Longtime User
I am trying to find out how to view server files and download the selected file i picked.

And if possible i could filler the result by keywords likes using a edittext.

I tried using FTP but i could never seem to make it work so i was wondering if there is a another way maybe using httpclient lib or something?

Please help as i been trying to do this for some time now but no luck.
 

rfresh

Well-Known Member
Licensed User
Longtime User
FTP is the solution you need to use. Fetch the files from the server and list them in some kind of view (component).

Then you can select one of the files from the listing.

Once selected, you can use FTP again to do the actual download to your device.

It will work fine. What you are trying to do is what FTP was made for.
 
Upvote 0

mdarkness

Member
Licensed User
Longtime User
can you give me the coding of how to do it for example using listview not list as list don't always display in layout.
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
Sorry, but I've never used the Listview...but maybe someone will jump in with some example code for you..
 
Upvote 0

mdarkness

Member
Licensed User
Longtime User
Its fine I have worked out how to do it now. I used ftp as u said and managed to place the info from ftp.list into a listview by playing around. Will share the code wen i can
 
Upvote 0

mdarkness

Member
Licensed User
Longtime User
B4X:
Sub Process_Globals

Dim FTP As FTP

End Sub


Sub Globals

Dim ListView1 As ListView

End Sub


Sub Activity_Create(FirstTime As Boolean)

FTP.Initialize("FTP", "127.0.0.1", 21, "user", "password")
FTP.PassiveMode=True
FTP.List("/")

End Sub


Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
     
     
   For i = 0 To Files.Length -1
        ListView1.AddSingleLine(Files(i).name)
    Next
    
   
   
   
End Sub
 
Upvote 0
Top