I have a program that needs to move a file from one directory to another on an FTP server. For example, the file is in:
ftp://1.1.1.1/MAIN/Dir1
U can use this code:
File original location "ftp://example.com/directory1/Somefile.file".
File to be moved, "/newDirectory/Somefile.file".
Note that destination Url not need start with: ftp://example.com
NetworkCredential User = new NetworkCredential("UserName", "password");
FtpWebRequest Wr =FtpWebRequest)FtpWebRequest.Create("ftp://Somwhere.com/somedirectory/Somefile.file");
Wr.UseBinary = true;
Wr.Method = WebRequestMethods.Ftp.Rename;
Wr.Credentials = User;
Wr.RenameTo = "/someotherDirectory/Somefile.file";
back = (FtpWebResponse)Wr.GetResponse();
bool Success = back.StatusCode == FtpStatusCode.CommandOK || back.StatusCode == FtpStatusCode.FileActionOK;