2

I want to upload a XML file on FTP via Code with unity, but i can't connect to the FTP first.

So before uploading I just try to access FTP and list directory.

I use this code:

FtpWebRequest request = (FtpWebRequest)WebRequest.Create(host);
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;

request.Credentials = new NetworkCredential(user, pass);

FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
Debug.Log(string.Format("Directory List Complete, status {0}", response.StatusDescription));

response.Close();

But I always have the same error :

Error : [Exception] Exception The authentication or decryption has failed.

Error : [Exception] Exception Server returned an error: 550-This server requires encryption. 550 You must issue the AUTH command to change to an encrypted session before you can attempt to login.

Looking for other post, I see that the authentication is Anonymous or mine is Normal.

Furthermore the FTP requires TLS protocol.

Thanks for helping me.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

1 Answers1

2

If your FTP server requires TLS/SSL encryption, you have to enable it using FtpWebRequest.EnableSsl:

request.EnableSsl = true;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • My bad, i forgot to add this for my try :/ that's why i had the error 550 :) i added it but no listing directory :/ – Cindy Vuillaume Jan 03 '18 at 15:14
  • If it helped this your first problem, accept the answer. And post a new question for your new problem. Do not change your question. – Martin Prikryl Jan 03 '18 at 15:15
  • you help for the second answer that is totally my mistake for forget to add enableSSL :) it's not my first question :) But for more visibility i will make a new post :) – Cindy Vuillaume Jan 03 '18 at 15:25