I've been struggling with that for the past few hours and I literally can't find a way to do it without downloading and uploading the file again. Is it even possible?
This question is kind of a copy of this one: How can I use FTP to move files between directories? but I have the feeling that its not solved, although it's answered.
Renaming the file itself is quite easy and works without any problems, but how do I move it to another directory?
I have this sample code:
string uri2 = "ftp://ftpUser@testFtp.com/mainFolder/moveFrom/file.txt";
f = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri2));
f.Credentials = new NetworkCredential(ftpUser, ftpPass);
f.KeepAlive = false;
f.UsePassive = true;
f.Method = WebRequestMethods.Ftp.Rename;
f.Timeout = 5000;
f.UseBinary = true;
f.RenameTo = "ftp://ftpUser@testFtp.com/mainFolder/moveTo/file.txt";
FtpWebResponse response = (FtpWebResponse)f.GetResponse();
response.Close();
f.Abort();
I get the same error as in the other topic:
The remote server returned an error: (550) File unavailable (e.g., file not found, no access).
Using a relative path, doesn't do anything different.
Do I do something wrong or is the only way to download from the source folder, upload to dest and then delete the file from the source? That's 3 calls to the FTP server..