// Create a FTP client to control our source server
FtpClient sourceClient = new FtpClient();
// Create a FTP client to control our destination server
FtpClient destinationClient = new FtpClient();
try
{
// Connect to the source server
sourceClient.Connect( "localhost", 21 );
/* FXP transfers cannot be performed over encrypted data channels. While it is ok
to encrypt the control channel, the data channel must remain clear. The DataChannelProtection.Clear
value ensures that. */
//sourceClient.Authenticate( AuthenticationMethod.Tls, VerificationFlags.None, null, DataChannelProtection.Clear );
// Login to the source server
sourceClient.Login( "normal", "normal" );
// Connect to the destination server
destinationClient.CertificateReceived += delegate( object sender, CertificateReceivedEventArgs e )
{
e.Action = VerificationAction.Accept;
};
destinationClient.Connect( "localhost", 10021 );
/* FXP transfers cannot be performed over encrypted data channels. While it is ok
to encrypt the control channel, the data channel must remain clear. The DataChannelProtection.Clear
value ensures that. */
//destinationClient.Authenticate( AuthenticationMethod.Ssl, VerificationFlags.None, null, DataChannelProtection.Clear );
// Login to the destination server
destinationClient.Login( "normal", "normal" );
/* For a FXP transfer, only one client can be setup for passive transfer.
The FxpServer enumeration allows to select either the source or destination client
as the one that will be setup as passive.
A FxpServer value is supplied to FtpClient.FxpCopy() */
FxpServer passiveServer = FxpServer.Source;
// Change the current folder on the source server to get to the file we want
sourceClient.ChangeCurrentFolder( "normal1" );
// Copy a file from the source server's current folder to the destination server giving the file a specific name
FtpClient.FxpCopy( sourceClient, "tvDebug.log", destinationClient, "FxpCopy.xml", passiveServer );
// Copy a file from a specific path on the source server to the destination server using the same name
FtpClient.FxpCopy( sourceClient, "/SftpFolder5/Folder2/ntprint.inf", destinationClient, "ntprint.inf", passiveServer );
// Copy a file from a specific path on the source server to a specific folder relative to the current folder on the destination server
FtpClient.FxpCopy( sourceClient, "/SftpFolder5/Folder2/ntprint.inf", destinationClient, "Folder2/ntprint.inf", passiveServer );
}
finally
{
if( sourceClient.Connected )
sourceClient.Disconnect();
if( destinationClient.Connected )
destinationClient.Disconnect();
}
' Create a FTP client to control our source server
Dim sourceClient As New FtpClient()
' Create a FTP client to control our destination server
Dim destinationClient As New FtpClient()
Try
' Connect to the source server
sourceClient.Connect("localhost", 21)
' FXP transfers cannot be performed over encrypted data channels. While it is ok
' to encrypt the control channel, the data channel must remain clear. The DataChannelProtection.Clear
' value ensures that.
'sourceClient.Authenticate( AuthenticationMethod.Tls, VerificationFlags.None, null, DataChannelProtection.Clear );
' Login to the source server
sourceClient.Login("normal", "normal")
' Connect to the destination server
AddHandler destinationClient.CertificateReceived, AddressOf AnonymousMethod1
destinationClient.Connect("localhost", 10021)
' FXP transfers cannot be performed over encrypted data channels. While it is ok
' to encrypt the control channel, the data channel must remain clear. The DataChannelProtection.Clear
' value ensures that.
'destinationClient.Authenticate( AuthenticationMethod.Ssl, VerificationFlags.None, null, DataChannelProtection.Clear );
' Login to the destination server
destinationClient.Login("normal", "normal")
' For a FXP transfer, only one client can be setup for passive transfer.
' The FxpServer enumeration allows to select either the source or destination client
' as the one that will be setup as passive.
'
' A FxpServer value is supplied to FtpClient.FxpCopy()
Dim passiveServer As FxpServer = FxpServer.Source
' Change the current folder on the source server to get to the file we want
sourceClient.ChangeCurrentFolder("normal1")
' Copy a file from the source server's current folder to the destination server giving the file a specific name
FtpClient.FxpCopy(sourceClient, "tvDebug.log", destinationClient, "FxpCopy.xml", passiveServer)
' Copy a file from a specific path on the source server to the destination server using the same name
FtpClient.FxpCopy(sourceClient, "/SftpFolder5/Folder2/ntprint.inf", destinationClient, "ntprint.inf", passiveServer)
' Copy a file from a specific path on the source server to a specific folder relative to the current folder on the destination server
FtpClient.FxpCopy(sourceClient, "/SftpFolder5/Folder2/ntprint.inf", destinationClient, "Folder2/ntprint.inf", passiveServer)
Finally
If sourceClient.Connected Then
sourceClient.Disconnect()
End If
If destinationClient.Connected Then
destinationClient.Disconnect()
End If
End Try