Solved adding the host to the username as described here
request.Credentials = new NetworkCredential(Host + "|" + Usuario, Clave);
题
I have a command line app that uploads to FTP. I've used it without problems, but know I have 2 FTP sites that have different hostnames and I seems that the FtpWebRequest don't send something to the server.
Using a ftp client (Beyond Compare) I have no problem.
The code that uploads:
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(target);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(Usuario, Clave);
request.UsePassive = Pasivo;
// Copy the contents of the file to the request stream.
byte[] fileContents = System.IO.File.ReadAllBytes(file);
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
It's there a way to send the HOST command?
More data:
解决方案
Solved adding the host to the username as described here
request.Credentials = new NetworkCredential(Host + "|" + Usuario, Clave);