c# - ftpe ://URI prefix is not recognized by FtpWebRequest

标签 c# .net ftp ftpwebrequest ftps

我有一个 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 prefix not recognized

请帮我解决我的问题。

最佳答案

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

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

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

关于c# - ftpe ://URI prefix is not recognized by FtpWebRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48897385/

相关文章:

Python:从 FTP 服务器检索多个文件

batch-file - 从包含两个独立模式的 FTP 服务器下载多个文件

c# - 是否可以通过 FTP 代理使用 C# FtpWebRequest?

c# - 在两个 asp.net mvc 应用程序之间共享 cookie

c# - 等待BackgroundWorker完成?

c# - 使用正则表达式 c# 递归地获取内部模式

.net - WPF ListView 虚拟化分组

c# - 如何在 C# WinRT 组件中使用 List<T> 或 Dictionary<T,T2>

C#:DateTime.DayOfWeek 与字符串比较

c# - Aspx C# MySQL 连接字符串未使用 web.Config 连接