Android Question Use Variables In Directory String

SpinBower

Member
Licensed User
Longtime User
Hi, I have a login form that when the login button is clicked it checks if that user exists. What I need is to use the Username variable in the directory for the list command. Here is my code:

B4X:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim Username As EditText
End Sub

Sub Login_Click
FTP.List("/public_html/users/Username.txt")
End Sub

Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
    Log(ServerPath)
    If Success = True Then
    If manager.Enabled = True Then
        RemoveViews
        Activity.LoadLayout("main2")
    Else
        RemoveViews
        Activity.LoadLayout("main")
    End If
    End If
End Sub
 

stevel05

Expert
Licensed User
Longtime User
Try

B4X:
FTP.List("/public_html/users/" & Username.Text & ".txt")
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I don't know, it's a simple concatenation of the contents of Username.text.

Try putting it into a string first and seeing what's being sent:

B4X:
Dim FTPString As String = "/public_html/users/" & Username.Text & ".txt"
Log(FTPString)
FTP.List(FTPString)
 
Upvote 0

SpinBower

Member
Licensed User
Longtime User
Ok so if I don't even put anything in the field it says that "/public_html/users/.txt" exists. I have no idea how that works!
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
How about if you set it as a string

B4X:
FTP.List("/public_html/users/.txt")
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
ftp.list returnes an array (or list or something) of files in the specified folder. So if you check this list aber ftp.list you´ll find no files there i suppose....

Specify an exiting folder ("/path/to/userfiles/"), get the list with

B4X:
filelist = ftp.list("public_html/path/to/userfiles/")

and iterate through it...

Please note: ftp.list is NOT a fileexists or folderexists.

See example from margret here.
 
Last edited:
Upvote 0

SpinBower

Member
Licensed User
Longtime User
The text file only has user data so it can never be over a 500kb. Also, if they try to download "thfhhvh.txt" they can't, because it's not there.
 
Upvote 0
Top