Xceed FTP Library Documentation
Receiving Files VB example
Example topics > Receiving Files VB example

 This example demonstrates the 7 following steps for receiving files:

  1. Specify the FTP server's address
  2. Specify the username to login
  3. Specify the password for the username
  4. Connect to the FTP server
  5. Receive files
  6. Disconnect from the FTP server
  7. Perform error handling

The following code assumes you have placed an XceedFtp control on a form and have called it 'XceedFtp1' (the default name).

Visual Basic Copy Code

Call XceedFtp1.License( "your license key" )

XceedFtp1.ServerAddress = "ftp.cdrom.com" ' step (1)
XceedFtp1.UserName = "anonymous" ' step (2)
XceedFtp1.Password = "guest" ' step (3)

On Error Resume Next ' step (7)

Call XceedFtp1.Connect ' step (4)

If Err.Number = 0 Then ' step (7)
   MsgBox "Successfully connected to server. Starting download."

   Call XceedFtp1.ReceiveFile("UPLOADS.TXT", 0, "c:\temp\cdrom_Uploads.txt") ' step (5)

   ' Use the ReceiveMultipleFiles method if you want to use wildcards to receive more than one file at a time.
   If Err.Number = 0 Then ' step (7)
      MsgBox "Successfully downloaded the file."
   Else
      MsgBox "Download error. Description: '" & Err.Description & "'. Error#" & Err.Number
   End If

   Call XceedFtp1.Disconnect ' step (6)
Else
   MsgBox "Connect error. Description: '" & Err.Description & "'. Error#" & Err.Number
End If