通过ftps操作文件

时间:2022-01-06 09:37:19
【文件属性】:

文件名称:通过ftps操作文件

文件大小:16KB

文件格式:RAR

更新时间:2022-01-06 09:37:19

ftps ftp ftp文件操作

版本是.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 < filelist.Count; i++) { client.GetFile("/ABC/" + filelist[i].Name.ToString(), AppDomain.CurrentDomain.BaseDirectory + "Download\\" + filelist[i].Name.ToString()); } --上传文件方法体 string sourcePath = AppDomain.CurrentDomain.BaseDirectory + "ABC\\"; 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); 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); }


【文件预览】:
AlexPilotti.FTPS.Client.dll

网友评论

  • 就是一个程序集,没用