NET FTP Library
RenameFile Method
Example 






KellermanSoftware.NetFtpLibrary Namespace > FTP 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 FTP
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
FTP ftp = new FTP(); //Trial Mode            
//FTP ftp = new FTP("place user name here", "place license key here");
 
// set the name of the FTP server( its URL )
ftp.HostAddress = "ftp.fsz.bme.hu"; // a hungarian university. change this to your ftp server
ftp.UserName = "anonymous"; // replace with your user name
ftp.Password = "user@mail.com"; // replace with your password
 
//Renames a file in the current FTP directory 
bool status = ftp.RenameFile("a.txt", "b.txt");
 
if (status == true)
    ftp.RenameFile("b.txt", "a.txt");
 
 
System.Console.WriteLine("a.txt has {0} renamed to newDir and back again", status == true ? "been" : "not been");
Dim ftp As FTP = New FTP() 'Trial Mode
'FTP ftp = new FTP("place user name here", "place license key here");
 
' set the name of the FTP server( its URL )
ftp.HostAddress = "ftp.fsz.bme.hu" ' a hungarian university. change this to your ftp server
ftp.UserName = "anonymous" ' replace with your user name
ftp.Password = "user@mail.com" ' replace with your password
 
'Renames a file in the current FTP directory
Dim status As Boolean = ftp.RenameFile("a.txt", "b.txt")
 
If status = True Then
   ftp.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

FTP Class
FTP Members