Click here to Skip to main content
15,887,822 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Error while upload/download file using FTPS (FTP over SSL) in C#

Error 1: The remote server returned an error: (501) Syntax error in parameters or arguments.

Error 2: The server returned an address in response to the PASV command that is different than the address to which the FTP connection was made.
Posted
Comments
Kornfeld Eliyahu Peter 12-Aug-14 7:32am    
If you can show us the code you used we may help you...
iftikharindher 12-Aug-14 7:41am    
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://SERVER-IP/tested.rar");
request.Method = WebRequestMethods.Ftp.UploadFile;
request.EnableSsl = true;
request.UsePassive = false;
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential("ftpUser", "ftpPassword");

// Copy the contents of the file to the request stream.
StreamReader sourceStream = new StreamReader("C:\\temps\\test.rar");
byte [] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;

Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();

FtpWebResponse response = (FtpWebResponse)request.GetResponse();

Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);

response.Close();

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900