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:
Occurs when the component has closed its
connection to the server.
|
|
Occurs when the component is about to
close its connection to the
server.
|
|
Occurs when the component has connected to
the server.
|
|
Occurs when the component is connecting to
the server.
|
|
Occurs when a file has been deleted from
the server.
|
|
Occurs when a file is about to be deleted
from the server.
|
|
Occurs when the working directory on the
server has been changed.
|
|
Occurs when the working directory on the
server is about to be changed.
|
|
Occurs when a file has been downloaded
from the server.
|
|
Occurs when a file is about to be
downloaded from the server.
|
|
Occurs when the component has logged in.
|
|
Occurs when the component is about to log
in.
|
|
Occurs when a remote file has been
renamed.
|
|
Occurs when a remote file is about to be
renamed.
|
|
Occurs when the component has secured the
connection to the server.
|
|
Occurs when the component is securing the
connection to the server.
|
|
Server validation event.
|
|
Occurs when a file has been uploaded to
the server.
|
|
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.
|
|
Occurs when a command is sent to the
server.
|
|
Occurs when an exception is thrown during
an asynchronous operation.
|
|
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.