Feb
25
2003

FTP Class

FTP Class based on the FileSystemObject using the Wininet Library

The FTP Class has been designed to mimmic the style of the FileSystemObject. There are two files (FTPClass.cls and FTPFileClass.cls). The Files and Folders properties in the FTPClass both return Collections of FTPFileClass objects.

This code has been revised (05 Sep 2003): Added the ability to connect using Passive FTP semantics.

What it can't do

  • Execute FTP commands

Usage

Add FTPClass.cls and FTPFileClass.cls to your project

   'This example opens a FTP connection, changes to a given folder and
   'downloads all the files contained in that folder to a local folder

   Dim ftp As FTPClass
   Dim f As FTPFileClass

   Set ftp = New FTPClass

   If ftp.OpenFTP("ftp.mydomain.com", "user", "pass") Then
      If ftp.SetCurrentFolder("MyFolder") Then
         For Each f In ftp.Files
            ftp.GetFile f.FileName, DownLoadFolder & "\" & f.FileName, True
         Next
      End If
      ftp.CloseFTP
   End If

   Set ftp = Nothing

Downloads

FTPClass.zip - contains: FTPClass.cls, FTPFileClass.cls (4 kb)

More...