Android Question Check If File Exists On FTP Server

SpinBower

Member
Licensed User
Longtime User
Hi, I have a button that when pressed needs to check if there is a file on the server that this specified in a text field. Is this possible?
 

SpinBower

Member
Licensed User
Longtime User
Upvote 0

sanduro

Member
Licensed User
Longtime User
it is exactly what you need lol :)

on button_click event call SendCommand (Command As String, Parameters As String)

B4X:
SendCommand ("LIST", youruserfiekd.text & ".txt")
 
Upvote 0

SpinBower

Member
Licensed User
Longtime User
it is exactly what you need lol :)

on button_click event call SendCommand (Command As String, Parameters As String)

B4X:
SendCommand ("LIST", youruserfiekd.text & ".txt")

Ok cool! So let's say the user doesn't exist, will it return something so the app can tell the user that it doesn't exist?
 
Upvote 0

sanduro

Member
Licensed User
Longtime User
dont be lazy and read those link I sent , everything is there :p

if i write you the code it will be my code and not yours, and read Erel's tutorial about FTP
 
Upvote 0

SpinBower

Member
Licensed User
Longtime User
So I have this:

How do I use the text field as the txt name in the list command?

B4X:
Sub Globals
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
        RemoveViews
        Activity.LoadLayout("main")
    End If
End Sub
 
Last edited:
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
Change the FTP_ListCompleted to this:

B4X:
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
    Log(ServerPath)
    If Success = True Then
        For i = 0 To Files().Size -1
            If Files(i).Name.Contains(Username.Text.Trim) Then
                'User File Found On Server
                RemoveViews
                Activity.LoadLayout("main")
            Else
                Msgbox("User Not Found...", "NOTICE")
            End If
        Next
    End If
End Sub
 
Upvote 0

SpinBower

Member
Licensed User
Longtime User
Change the FTP_ListCompleted to this:

B4X:
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
    Log(ServerPath)
    If Success = True Then
        For i = 0 To Files().Size -1
            If Files(i).Name.Contains(Username.Text.Trim) Then
                'User File Found On Server
                RemoveViews
                Activity.LoadLayout("main")
            Else
                Msgbox("User Not Found...", "NOTICE")
            End If
        Next
    End If
End Sub

Thanks!
 
Upvote 0

SpinBower

Member
Licensed User
Longtime User
Sorry but it returns with an error

Parsing code. 0.00
Compiling code. Error
Error compiling program.
Error description: Missing parameter.
Occurred on line: 77
For i = 0 To Files().Size -1
Word: (
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
To give this thread a "completed" you can share the solution back to others...
 
Upvote 0
Top