Unfortunately, copying a file from one FTP folder to another is not supported by the FTP protocol.
Possible solutions:
1) The easiest way to achieve this is to download the file and re-upload it to a different folder. Of course, this is very slow.
2) Use CopyToAnotherServer method - create two FTP sessions to the same server and use FXP functionality to copy the file to "another" server (which is actually the same server):
Ftp session1 = new Ftp();
session1.Connect(server1);
session1.Login(username1, password1);
Ftp session2 = new Ftp();
session2.Connect(server1);
session2.Login(username1, password1);
session1.CopyToAnotherServer(session2, sourcePath, destinationPath);
Most servers will require "FXP", or "server-to-server transfer" to be enabled for this to work, even though no transfer to another server actually takes place. This is usually disabled by default.
3) If your FTP server supports defining custom sub-commands for SITE
command, define a COPY
command that executes 'cmd.exe /c copy "source" "target"'
command (the exact way of doing that depends on the FTP server (and not all servers support custom commands).