Overview
Using the FTP library you can connect the device or desktop to a ftp server and download
or upload from it.
The device / desktop should be connected to the internet.
Note that connecting to an ftp library when the device is connected to the internet using
Activesync is not recommended and may not work properly.
Working with this library is pretty simple.
First add a reference to this library using the Components dialog.
Add an object of that type using Tools - Add Object.
Initialize the object with the New1 method.
Connect to the ftp server with the Open method (include user user name and password if
necessary).
Upload or download files.
Close the connection with the Close method.
Example:
This example requires an ftp object named ftp, a table named table1 and a button named
btnDownload.
Sub Globals
dim entries(0) 'This array will be filled by the GetEntries
method.
End Sub
Sub App_Start
Form1.Show
ftp.New1
ftp.Open("ftp.ftpplanet.com","","") 'No
user name or password
required here.
ftp.SetCurrentDirectory("images")
table1.AddCol(cString,"name",60)
table1.AddCol(cString,"date",60)
table1.AddCol(cNumber,"size",60)
FillEntries
End Sub
Sub FillEntries 'Fills the table with the directories and files
entries() = ftp.GetEntries("",true) 'Get
all subdirectories first.
for i = 0 to arraylen(entries())-1 step 3 'Each
entry includes 3
values: name, date (ticks) and size.
table1.AddRow(entries(i),date(entries(i+1)),entries(i+2))
next
entries() = ftp.GetEntries("",false) 'Get
all files now.
for i = 0 to arraylen(entries())-1 step 3
table1.AddRow(entries(i),date(entries(i+1)),entries(i+2))
next
End Sub
Sub btnDownload_Click
WaitCursor(true)
name = table1.Cell("name",table1.SelectedRow)
ftp.GetFile(name,AppPath & "\" & name)
WaitCursor(false)
End Sub
Sub Form1_Close
ftp.Close 'Close the connection.
End Sub