NET SFTP Library
MoveFile Method
Example 






KellermanSoftware.NetSFtpLibrary Namespace > SFTP Class : MoveFile Method
The old path and file name
The new path and file name
Move a file on the SFTP Server
Syntax
'Declaration
 
Public Function MoveFile( _
   ByVal oldPathAndName As System.String, _
   ByVal newPathAndName As System.String _
) As System.Boolean
'Usage
 
Dim instance As SFTP
Dim oldPathAndName As System.String
Dim newPathAndName As System.String
Dim value As System.Boolean
 
value = instance.MoveFile(oldPathAndName, newPathAndName)
public System.bool MoveFile( 
   System.string oldPathAndName,
   System.string newPathAndName
)
public function MoveFile( 
    oldPathAndName: System.String;
    newPathAndName: System.String
): System.Boolean; 
public function MoveFile( 
   oldPathAndName : System.String,
   newPathAndName : System.String
) : System.boolean;
public: System.bool MoveFile( 
   System.string* oldPathAndName,
   System.string* newPathAndName
) 
public:
System.bool MoveFile( 
   System.String^ oldPathAndName,
   System.String^ newPathAndName
) 

Parameters

oldPathAndName
The old path and file name
newPathAndName
The new path and file name

Return Value

True if the move was successful
Example
SFTP sftp = new SFTP(); //Trial Mode            
//SFTP sftp = new SFTP("place user name here", "place license key here");
 
// set the name of the SFTP server( its URL )
sftp.HostAddress = "some.sftp.server.com"; // replace with your sftp server
sftp.UserName  = "anonymous"; // replace with your user name
sftp.Password = "user@mail.com"; // replace with your password
 
//Move a file from one directory to another
bool status = sftp.MoveFile("/ZTEST/InnerDirectory1/TestFile.txt", "/ZTEST/InnerDirectory2/TestFile.txt");
Dim sftp As SFTP = New SFTP() 'Trial Mode
'Dim sftp = New SFTP("place user name here", "place license key here")
 
' set the name of the SFTP server( its URL )
sftp.HostAddress = "some.sftp.server.com" ' replace with your sftp server
sftp.UserName  = "anonymous" ' replace with your user name
sftp.Password = "user@mail.com" ' replace with your password
 
'Renames a file in the current FTP directory
Dim status As Boolean = sftp.MoveFile("/ZTEST/InnerDirectory1/TestFile.txt", "/ZTEST/InnerDirectory2/TestFile.txt")
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