NET SFTP Library
RenameFile Method
Example 






KellermanSoftware.NetSFtpLibrary Namespace > SFTP Class : RenameFile Method
The current file name
The new file name
Renames a file in the current FTP directory.
Syntax
'Declaration
 
Public Function RenameFile( _
   ByVal oldName As System.String, _
   ByVal newName As System.String _
) As System.Boolean
'Usage
 
Dim instance As SFTP
Dim oldName As System.String
Dim newName As System.String
Dim value As System.Boolean
 
value = instance.RenameFile(oldName, newName)
public System.bool RenameFile( 
   System.string oldName,
   System.string newName
)
public function RenameFile( 
    oldName: System.String;
    newName: System.String
): System.Boolean; 
public function RenameFile( 
   oldName : System.String,
   newName : System.String
) : System.boolean;
public: System.bool RenameFile( 
   System.string* oldName,
   System.string* newName
) 
public:
System.bool RenameFile( 
   System.String^ oldName,
   System.String^ newName
) 

Parameters

oldName
The current file name
newName
The new file name
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
 
//Renames a file in the current FTP directory 
bool status = sftp.RenameFile("a.txt", "b.txt");
 
if (status == true)
    sftp.RenameFile("b.txt", "a.txt");
 
 
System.Console.WriteLine("a.txt has {0} renamed to newDir and back again", status == true ? "been" : "not been");
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.RenameFile("a.txt", "b.txt")
 
If status = True Then
   sftp.RenameFile("b.txt", "a.txt")
End If
 
 
If status = True Then
    System.Console.WriteLine("a.txt has {0} renamed to newDir and back again","been")
Else
    System.Console.WriteLine("a.txt has {0} renamed to newDir and back again","not been")
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