我有一个上传到FTP的命令行应用程序。我已经毫无问题地使用它了,但是知道我有2个具有不同主机名的FTP站点,而且我似乎FtpWebRequest不会向服务器发送内容。
使用ftp客户端(Beyond Compare)我没问题。
上传的代码:
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();
有没有办法发送HOST命令?
更多数据:
答案 0 :(得分:0)
已解决将主机添加到here
所述的用户名 request.Credentials = new NetworkCredential(Host + "|" + Usuario, Clave);