Hello,
I am trying to create a backup of the file using this code block:
FtpWebResponse webResponse = null;
string archiveFolder = "/Archive/Tuesday/";
string fileUri = "ftp://Test/TestDropPoint/Prod/HELLO5.TXT";
int lastSlash = fileUri.LastIndexOf("/");
if (lastSlash != -1)
{
lastSlash++;
}
string name = fileUri.Substring(lastSlash, fileUri.Length - lastSlash);
FtpWebRequest webReq = (FtpWebRequest)FtpWebRequest.Create(fileUri);
webReq.Credentials = new NetworkCredential(FtpUsername, FtpUserPassword);
webReq.EnableSsl = FtpEnableSSL;
webReq.UseBinary = FtpBinary;
webReq.UsePassive = FtpUsePassive;
webReq.KeepAlive = false;
webReq.Method = WebRequestMethods.Ftp.Rename;
webReq.RenameTo = archiveFolder + name;
webReq.ConnectionGroupName = "MoveFile";
webReq.ServicePoint.CloseConnectionGroup("MoveFile");
webResponse = (FtpWebResponse)webReq.GetResponse();
But I receive this error: WebResponse = 553 File name is not allowed.
System.Net.WebException: The remote server returned an error: (553) File name not allowed.
Here is my reference but still didnot work: https://social.msdn.microsoft.com/Forums/en-US/8c541130-b571-4b1a-9117-ac610f3e8b34/ftpwebrequestrenameto-property?forum=netfxnetcom
Kindly help.