NET FTP Library
MoveFile Method
Example 






KellermanSoftware.NetFtpLibrary Namespace > FTP Class : MoveFile Method
The old path and file name
The new path and file name
Move a file on the FTP Server
Syntax
'Declaration
 
Public Function MoveFile( _
   ByVal oldPathAndName As System.String, _
   ByVal newPathAndName As System.String _
) As System.Boolean
'Usage
 
Dim instance As FTP
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
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
 
//Move a file from one directory to another
bool status = ftp.MoveFile("/ZTest/InnerDirectory1/TestFile.txt", "/ZTest/InnerDirectory2/TestFile.txt");
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.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

FTP Class
FTP Members