本文介绍了FtpWebRequest无法识别ftpes:// URI前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个FTP域,必须将文件txt上传到其FTP服务器,该FTP域看起来像 ftpes://domain.com ,但我从未见过 ftpes 之前,但是当我通过FileZilla上传时,它可以成功上传,但是如果我使用我的这段代码

I have an FTP domain that I must to upload file txt to its FTP server the FTP domain looks like ftpes://domain.com, I never see the ftpes before, but when I upload by FileZilla it works success upload, but if I using my this code

FtpWebRequest ftpClient = (FtpWebRequest)FtpWebRequest.Create(FTPdestination+ i + ".txt");
ftpClient.Credentials = new System.Net.NetworkCredential(user, pass);
ftpClient.Method = System.Net.WebRequestMethods.Ftp.UploadFile;
ftpClient.UseBinary = true;
ftpClient.EnableSsl = true;
ftpClient.KeepAlive = true;
System.IO.FileInfo fi = new System.IO.FileInfo(server+dtm+"_"+i+".txt");
ftpClient.ContentLength = fi.Length;
byte[] buffer = new byte[4097];
int bytes = 0;
int total_bytes = (int)fi.Length;
System.IO.FileStream fs = fi.OpenRead();
System.IO.Stream rs = ftpClient.GetRequestStream();
while (total_bytes > 0)
{
    bytes = fs.Read(buffer, 0, buffer.Length);
    rs.Write(buffer, 0, bytes);
    total_bytes = total_bytes - bytes;
}
fs.Close();
rs.Close();
FtpWebResponse uploadResponse = (FtpWebResponse)ftpClient.GetResponse();
uploadResponse.Close();

错误消息是

请帮助我解决问题。

推荐答案

ftpes:// 不是标准协议前缀。但是它被一些 FTP客户端识别为通过TLS / SSL的显式FTP

ftpes:// is not a standard protocol prefix. But it is recognized by some FTP clients to mean "Explicit FTP over TLS/SSL".

使用 FtpWebRequest 可以通过使用标准 ftp:// 协议前缀并设置 EnableSsl = true (您已经做了什么)。

With FtpWebRequest you specify that by using standard ftp:// protocol prefix and setting EnableSsl = true (what you do already).

另请参见

这篇关于FtpWebRequest无法识别ftpes:// URI前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-08 23:07