【发布时间】:2018-06-28 21:10:42
【问题描述】:
我的代码的目的是将一些数据上传到 FTP 位置。
使用我的代码时,我不断收到一条错误消息,指出远程服务器需要 SSL。我正在使用大于 4 的 .NET 版本。所有其他帖子都建议我添加下面的ServicePointManager 代码。
异常发生在client.UploadData。
仍然没有骰子。任何帮助将不胜感激。
ServicePointManager.ServerCertificateValidationCallback +=
(sender,certificate, chain, sslPolicyErrors) => true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
byte[] data = stream.ToArray(); //Data I want to upload to FTP location
using (WebClient client = new WebClient())
{
client.Credentials = new NetworkCredential("*Username*", "*Password*");
client.UploadData("ftp://file.example.com/Content/file", "STOR", data);
}
【问题讨论】:
标签: c# .net ftp webclient ftps