The ftpes:// URI prefix is not recognized by FtpWebRequest

Deadly 提交于 2019-12-01 05:32:25

问题


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();

The error message is

URI prefix not recognized

Please help me to solve my case.


回答1:


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

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

See also Does .NET FtpWebRequest Support both Implicit (FTPS) and explicit (FTPES)?



来源:https://stackoverflow.com/questions/48897385/the-ftpes-uri-prefix-is-not-recognized-by-ftpwebrequest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!