版本是.net3.5加密FTP文件操作,利用FTPS实现文件上传,下载,删除操作。
string ftpIP = "";//FTP ip
string ftpUSER = "";//FTP 用户名
string ftpPWD = "";//FTP 密码
--下载文件方法体
FTPSClient client = new FTPSClient();
client.Connect(ftpIP,
new NetworkCredential(ftpUSER, ftpPWD),
ESSLSupportMode.CredentialsRequired | ESSLSupportMode.Implicit,
new RemoteCertificateValidationCallback((a, b, c, d) => { return true; }));
client.SetTransferMode(ETransferMode.Binary);
client.SetTextEncoding(ETextEncoding.UTF8);
IList filelist = client.GetDirectoryList("/ABC/");
for (int i = 0; i { return true; }));
client.SetTransferMode(ETransferMode.Binary);
client.SetTextEncoding(ETextEncoding.UTF8);
DirectoryInfo di = new DirectoryInfo(sourcePath + "\\");
FileInfo[] files = di.GetFiles();
for (int i = 0; i < files.Length; i++)
{
client.PutFile(sourcePath + "\\" + files[i].Name, "/ABC/" + files[i].Name);
//删除原文件
File.Copy(sourcePath + "\\" + files[i].Name, sourcePath + "_Bak\\" + files[i].Name, true);
File.Delete(sourcePath + "\\" + files[i].Name);
}
1