I have built an Console Application that reads and move files from a remote FTP. Everything has gone smoothly until I deployed the code to the production environment.
The first thing I ask for when I connect to the FTP is the listDirectory which works in both environments. After that I try to move files from the root but that only works in the dev environment!? In production I get following error code: "The remote server returned an error (451) local error in processing"
Here is the code for moving one file:
var uri = new Uri("ftp://ftp.example.com/test.xml");
var request = (FtpWebRequest)WebRequest.Create(uri);
request.Credentials = new NetworkCredential(_username, _password);
request.UsePassive = true;
request.Method = WebRequestMethods.Ftp.Rename;
request.RenameTo = "/folder/test.xml";
(FtpWebResponse)request.GetResponse();
Should also mention that I'am able to move files in production by using the command line:
ftp ftp.example.com
Username: .....
Password: .....
rename test.xml /folder/test.xml
250 File successfully renamed or moved
I have ran out of ideas, so all help is appreciated!
PS. I connect to the same FTP host with the same credentials in both enviroments and I can also read files in both environments.