【问题标题】:The ftpes:// URI prefix is not recognized by FtpWebRequestFtpWebRequest 无法识别 ftpes:// URI 前缀
【发布时间】:2018-02-21 02:40:58
【问题描述】:

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

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

错误信息是

URI 前缀无法识别

请帮我解决我的问题。

【问题讨论】:

    标签: c# .net ftp ftpwebrequest ftps


    【解决方案1】:

    ftpes:// 不是标准协议前缀。但一些 FTP 客户端识别它是指“基于 TLS/SSL 的显式 FTP”

    使用FtpWebRequest,您可以使用标准的ftp:// 协议前缀并设置EnableSsl = true(您已经执行的操作)来指定。

    另见Does .NET FtpWebRequest Support both Implicit (FTPS) and explicit (FTPES)?

    【讨论】:

      猜你喜欢
      • 2023-03-05
      • 2020-03-23
      • 1970-01-01
      • 1970-01-01
      • 2013-07-26
      • 1970-01-01
      • 2021-09-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多