NET SFTP Library
SiteToSiteTransferFile Method
Example 






KellermanSoftware.NetSFtpLibrary Namespace > SFTP Class : SiteToSiteTransferFile Method
Transfer specified by name file from current SFTP to destination SFTP.
Syntax
'Declaration
 
Public Sub SiteToSiteTransferFile( _
   ByVal destination As SFTP, _
   ByVal fileName As System.String _
) 
'Usage
 
Dim instance As SFTP
Dim destination As SFTP
Dim fileName As System.String
 
instance.SiteToSiteTransferFile(destination, fileName)
public void SiteToSiteTransferFile( 
   SFTP destination,
   System.string fileName
)
public procedure SiteToSiteTransferFile( 
    destination: SFTP;
    fileName: System.String
); 
public function SiteToSiteTransferFile( 
   destination : SFTP,
   fileName : System.String
);
public: void SiteToSiteTransferFile( 
   SFTP* destination,
   System.string* fileName
) 
public:
void SiteToSiteTransferFile( 
   SFTP^ destination,
   System.String^ fileName
) 

Parameters

destination
fileName
Example
//Connect to the source
SFTP sftpSource = new SFTP();
sftpSource.HostAddress = "source server address";
sftpSource.UserName = "source user name";
sftpSource.Password = "source password";
sftpSource.EnableLogging();
sftpSource.Connect();
 
//Create a source directory on the source SFTP server
sftpSource.CreateDirectory("SourceDir");
sftpSource.CurrentDirectory = "SourceDir";
 
//Create a test file and upload to the source directory
File.WriteAllText("test.txt", "This is a test");
sftpSource.UploadFile("test.txt", "test.txt");
 
//Connect to the destination
SFTP sftpDest = new SFTP();
sftpDest.HostAddress = "dest server address"; 
sftpDest.UserName = "dest user name";
sftpDest.Password = "dest password";
sftpDest.EnableLogging();
sftpDest.Connect();
 
//Create a dest directory on the dest SFTP server
sftpDest.CreateDirectory("DestDir");
sftpDest.CurrentDirectory = "DestDir";
 
sftpSource.SiteToSiteTransferFile(sftpDest,"test.txt");
 
if (sftpDest.FileExists("test.txt"))
    Console.WriteLine("Success!");
'Connect to the source
Dim sftpSource As New SFTP()
sftpSource.HostAddress = "source server address"
sftpSource.UserName = "source user name"
sftpSource.Password = "source password"
sftpSource.EnableLogging()
sftpSource.Connect()
 
'Create a source directory on the source SFTP server
sftpSource.CreateDirectory("SourceDir")
sftpSource.CurrentDirectory = "SourceDir"
 
'Create a test file and upload to the source directory
File.WriteAllText("test.txt", "This is a test")
sftpSource.UploadFile("test.txt", "test.txt")
 
'Connect to the destination
Dim sftpDest As New SFTP()
sftpDest.HostAddress = "dest server address"
sftpDest.UserName = "dest user name"
sftpDest.Password = "dest password"
sftpDest.EnableLogging()
sftpDest.Connect()
 
'Create a dest directory on the dest SFTP server
sftpDest.CreateDirectory("DestDir")
sftpDest.CurrentDirectory = "DestDir"
 
sftpSource.SiteToSiteTransferFile(sftpDest,"test.txt")
 
If sftpDest.FileExists("test.txt") Then
    Console.WriteLine("Success!")
End If
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

Reference

SFTP Class
SFTP Members