Skip to content

FTP Download Example

Andrew Lambert edited this page Sep 26, 2023 · 15 revisions

Single file

This example performs a synchronous FTP download on the calling thread.

Dim c As New cURLClient
c.Username = "username"
c.Password = "seekrit"
Dim outputfile As FolderItem = SpecialFolder.Desktop.Child("file.zip")
Dim outputstream As BinaryStream = BinaryStream.Create(outputfile)
If Not c.Get("ftp://ftp.example.com/bin/file.zip", outputstream) Then
  MsgBox(libcURL.FormatError(c.LastError))
End If
outputstream.Close()

Multiple files using wildcards

This example uses the FTPWildCard class to download all zip files in the remote directory:

  Dim outputdir As FolderItem = SelectFolder()
  Dim w As New libcURL.FTPWildCard
  w.LocalRoot = outputdir

  Dim c As New cURLClient(w) ' pass the FTPWildCard to cURLSession.Constructor(EasyHandle)
  c.Username = "username"
  c.Password = "seekrit"
  If Not c.Get("ftp://ftp.example.com/bin/*.zip") Then ' use a pattern in the URL
     MsgBox(libcURL.FormatError(c.LastError))
  End If
  outputdir.Launch
Clone this wiki locally