Xceed .NET Libraries Documentation
MultipleFileTransferError Event
Example 


Xceed.Ftp Assembly > Xceed.Ftp Namespace > FtpClient Class : MultipleFileTransferError Event
Raised when an error occurs while transferring multiple files to or from the FTP server to determine what action should be taken.
Syntax
'Declaration
 
Public Event MultipleFileTransferError As MultipleFileTransferErrorEventHandler
'Usage
 
Dim instance As FtpClient
Dim handler As MultipleFileTransferErrorEventHandler
 
AddHandler instance.MultipleFileTransferError, handler
public event MultipleFileTransferErrorEventHandler MultipleFileTransferError
Event Data

The event handler receives an argument of type MultipleFileTransferErrorEventArgs containing data related to this event. The following MultipleFileTransferErrorEventArgs properties provide information specific to this event.

PropertyDescription
Gets or sets a value indicating the action to take for the file failed to be transferred during a multiple-file transfer.  
Gets the exception that was thrown while attempting to transfer a file during a multiple-file transfer.  
Gets the local path and name of the item that failed to be transferred during a multiple-file transfer.  
Gets the remote name of the item that failed to be transferred during a multiple-file transfer.  
Gets or sets the type of the remote item which failed to be transferred during a multiple-file transfer.  
Remarks

This event can only be raised by the SendMultipleFiles or ReceiveMultipleFiles methods.

Other methods of the FTP client must not be called in this event handler! For example, DeleteFile cannot be called to delete an existing file so that the file transfer (for that particular file) can be retried.

Example
The following example demonstrates how to use the MultipleFileTransferError event to continue downloading during the multiple-file transfer even when one of the files causes an error. This example assumes that you are in a Windows application and that the form contains a listbox.
Xceed.Ftp.Licenser.LicenseKey = "FTNXX-XXXXX-XXXXX-XXXX" ' Set license key here to deploy 

Dim ftp As New FtpClient()

AddHandler ftp.MultipleFileTransferError, AddressOf Me.transfer_error

ftp.Connect( "localhost" )
ftp.Login()

ftp.ChangeCurrentFolder( "ClientFiles" )
ftp.ReceiveMultipleFiles( String.Empty, "C:\ClientFiles", False, False )

ftp.Disconnect()

Private Sub transfer_error( ByVal sender As Object, ByVal e As MultipleFileTransferErrorEventArgs )

  If TypeOf e.Exception Is FtpReplyException Then
    ListBox1.Items.Add("Unable to transfer " + e.RemoteItemName + _
                       ". The message returned by the FTP server was : " + e.Exception.Message)
    e.Action = MultipleFileTransferErrorAction.Ignore
  End If
End Sub
Xceed.Ftp.Licenser.LicenseKey = "FTNXX-XXXXX-XXXXX-XXXX" // Set license key here to deploy 

FtpClient ftp = new FtpClient();

ftp.MultipleFileTransferError += new MultipleFileTransferErrorEventHandler( this.transfer_error );

ftp.Connect( "localhost" );
ftp.Login();

ftp.ChangeCurrentFolder( "ClientFiles" );
ftp.ReceiveMultipleFiles( string.Empty, @"C:\ClientFiles", false, false );

ftp.Disconnect();

private void transfer_error( object sender, MultipleFileTransferErrorEventArgs e )
{
  FtpReplyException exception = e.Exception as FtpReplyException;
  
  if( exception != null )
  {
    listBox1.Items.Add( "Unable to transfer " + e.RemoteItemName + 
                        ". The message returned by the FTP server was : " + e.Exception.Message ); 
    e.Action = MultipleFileTransferErrorAction.Ignore; 
  }
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also