edtFTPnet/PRO - Secure FTP component for .NET | Free Trial | Pricing

How to use FTP events

edtFTPnet/PRO's events are useful for providing feedback on the progress of FTP operations. For example, the BytesTransferred event fires during a file transfer each time another n bytes have been transferred, where n is equal to FTPConnection.TransferNotifyInterval.  An event such as this may be used to provide progress feedback during long transfer operations.

Handling events is done using delegates in the same way as other .NET events.  For example, to handle the Connected event, an event handler must be defined:

privatevoid ftpConnection_Connected(object sender, EnterpriseDT.Net.Ftp.FTPConnectionEventArgs e)
{
	Print("Connected to "; + e.ServerAddress + ":" + e.ServerPort);
}

A delegate for this event-handler must then be added to the event:

ftpConnection.Connected += new FTPConnectionEventHandler(ftpConnection_Connected);

Once this has been done, the ftpConnection_Connect method will be called when a connection with the server has been established.

The following events relate to specific FTP operations. Most events are available in FTPConnection, however certain security-related events are only available in SecureFTPConnection:

Closed
Occurs when the component has closed its connection to the server.

Closing
Occurs when the component is about to close its connection to the server.

Connected
Occurs when the component has connected to the server.

Connecting
Occurs when the component is connecting to the server.

Deleted
Occurs when a file has been deleted from the server.

Deleting
Occurs when a file is about to be deleted from the server.

DirectoryChanged
Occurs when the working directory on the server has been changed.

DirectoryChanging
Occurs when the working directory on the server is about to be changed.

Downloaded
Occurs when a file has been downloaded from the server.

Downloading
Occurs when a file is about to be downloaded from the server.

LoggedIn
Occurs when the component has logged in.

LoggingIn
Occurs when the component is about to log in.

RenamedFile
Occurs when a remote file has been renamed.

RenamingFile
Occurs when a remote file is about to be renamed.

SecuredConnection
Occurs when the component has secured the connection to the server.

SecuringConnection
Occurs when the component is securing the connection to the server.

ServerValidate
Server validation event.

Uploaded
Occurs when a file has been uploaded to the server.

Uploading
Occurs when a file is about to be uploaded to the server.

The following events are of a more general nature and can occur across a range of FTP operations:


Occurs every time a specified number of bytes of data have been transferred.

CommandSent
Occurs when a command is sent to the server.

Error
Occurs when an exception is thrown during an asynchronous operation.

ReplyReceived
Occurs when a reply is received from the server.

The Error event is of particular importance when using asynchronous processing since it is called if an exception is thrown occurs during an FTP operation.  The topic How to use asynchronous methods has information about using events with asynchronous methods.