EZFTP ActiveX Control
Updated May 17, 1996
The EZFTP ActiveX Control encapsulates most of the functionality of an FTP client. By setting a few properties, FTP transfers can be easily done from within Visual Basic or any application that is an ActiveX container.
Although there are many other FTP OCXes available, I wrote EZFTP after reading through the Sweeper SDK documentation released by Microsoft. Microsoft encapsulated the FTP, HTTP and Gopher protocols into a DLL provided with the SDK and EZFTP uses this DLL rather than communicating directly with WinSock. In fact, there is no WinSock code at all in EZFTP!
EZFTP.OCX is owned and copyrighted by COOL.STF. You may use EZFTP with any application without royalties or fees. Note that this free version of EZFTP only supports synchronous operation. This means that if you request a large file from a remote FTP server, control will be returned to your application only when the transfer has completed or has failed.
A Professional Edition of EZFTP is available. It allows you to drive a progress indicator and also abort the transfer. Registered users of the Professional Edition can also obtain a pre-release copy of EZFTP 2.0 beta, which allows true-async operation - you can have multiple FTP transfers occuring on the same form. Please see our Order Page for details.
There is currently no flashy installation program, but all you need to do is:
If you don't have the MFC/OLE DLLs or don't have the latest versions, they can be downloaded from our site.
UserName - string
Set to the user name to log on with. For anonymous transfers, set to "anonymous".
Password - string
Set to the password to log on with. For anonymous transfers, set to an email address, for example "email@example.com".
LocalFile - string
Set to the name of the local file to be transferred to or from. For example, "c:\windows\desktop\myfile.txt".
RemoteFile - string
Set to the name of the remote file to be transferred to or from. For example, "/home/myacct/etc/stuff.txt".
Binary - boolean
Set as appropriate for the file transfer mode. If transferring ASCII files, should be false to allow <lf> to <cr><lf> translations when moving files between the PC and a Unix machine. If transferring binary files, set true.
RemoteAddress - string
Sets the address of the remote FTP server. Accepts either domain names, for example "ftp.domain.com" or IP addresses, for example "18.104.22.168".
RemoteDirectory - string
Sets or returns the directory in use on the remote FTP server. For example:
might display "/usr/bin/rod". To change directory on the remote server, use:
EZFTP1.RemoteDirectory = "/usr/barney/hate/hate/hate"
provided the directory exists on the remote system (doesn't every machine have a /usr/barney/hate/hate/hate directory!!).
Opens a connection to the remote FTP server specified in RemoteAddress.
Closes the connection with the remote FTP server previously opened with Connect. You must take care to issue a Disconnect after a successful Connect. Failure to do so will leave an open FTP connection on the server.
Receives the remote file specified in RemoteFile and stores it locally in the file specified by LocalFile. Overwrites the local file if it already exists. For example:
EZFTP1.RemoteFile = "/etc/termcap"
EZFTP1.LocalFile = "c:\windows\desktop\termcap.txt"
On Error Resume Next
If Err <> 0 Then
MsgBox "Unable to get file. Error code : " & Format$(Err.Number)
Transfers the local file specified by LocalFile to the file specified by RemoteFile on the FTP server.
MkDir (Directory as string)
Creates a directory specified by the string Directory on the remote FTP server.
RmDir (Directory as string)
Removes the directory specified by the string Directory on the remote FTP server.
RenameFile (OldName as string, NewFile as string)
Renames the file specified in OldName to NewFile on the remote FTP server.
DeleteFile (FileName as string)
Deletes the file specified in FileName on the remote FTP server.
GetDirectory (FileName as string)
Gets a directory listing for the remote system. Wildcards may be specified in the FileName string. Fires the NextDirectoryEvent for each file that is reported by the remote FTP server. For example:
On Error Resume Next
'Get the directory. Work actually done in the NextDirectoryEntry event
'Arrive here after all possible files have been returned
If Err <> 0 Then
MsgBox "Unable to get directory. Error: " & format$(Err.Number)
NextDirectoryEntry (FileName As String, Attributes As Long, Length As Double)
Fires for each file that is returned by the remote FTP server after a GetDirectory method is used.
Contains the name of the file on the remote system
Contains bit flags indicating the type of the file.
Contains the length of the file in bytes.
The RemoteDirectory property when written to and all methods can generate runtime errors. For example, attempting to receive a file that doesn't exist with the GetFile method will generate a runtime error. Therefore, it is important to ensure that error handling routines are provided for the methods and the RemoteDirectory property.
If an error occurs, Err.Number can be set to one of the following values. The errors without an explanation should never be seen. If you do encounter one of these errors, be sure to let us know what you did to generate the error. Send email to firstname.lastname@example.org
1000 General Error.
1001 Out of handles.
1002 Timeout. The operation was aborted because the remote system didn't respond.
1003 Extended error.
1004 Internal error.
1005 Invalid URL.
1006 Unrecognized scheme.
1006 Name not resolved. The remote domain name couldn't be resolved.
1008 Protocol not found.
1009 Invalid option.
1010 Bad option length.
1011 Option not settable.
1013 Incorrect user name. The user name specified in the UserName property was not accepted by the remote system.
1014 Incorrect password. The password specified in the Password property was not accepted by the remote system.
1015 Login failure. The server didn't allow the user name / password combination.
1016 Invalid operation.
1017 Operation cancelled.
1018 Incorrect handle type.
1019 Not local handle.
1020 Not proxy request.
1021 Internet registry value not found.
1022 Bad registry parameter.
1023 No direct access.
1027 Transfer in progress.
1028 FTP connected.
1029 FTP disconnected. The remote system unexpectedly closed the connection.
Additionally, Err.Description contains an description of the error, plus any extra error information returned by the FTP interface, separated by a colon. For example:
Unable to connect to FTP server: 220-Welcome to the Internet
Interstate FTP server!
220 sheldon FTP server (Version wu-2.4(1) Thu Aug 17 09:56:25 EDT 1995) ready.
331 Password required for xx.
530 Login incorrect.