FTPS(FTP+SSL) 资料上传

最近因客户FTP 升级,将之前的FTP 升级为FTPS,就是ftp连接加密,加密方法是用SSL 加密。

方案一 使用第三方工具

     是用Flashxp 工具自定义Schedure, 实现自动上传功能。缺点:1.目标文件需另外生成,有时间间隔,无法达到及时上传。2.对于上传失败无法做出处理,虽然有log但仍旧有文件丢失。

方案二 使用DLL

    引用AlexPilotti.FTPS.Client 到目标程序中,使用以下方法上传:

          
 

               using (FTPSClient client = new FTPSClient())
                {
                    NetworkCredential netCredential = new NetworkCredential(this._UserName, this._PassWord);
                    client.Connect(
                        this._strHostName,
                        21,
                        netCredential,
                        ESSLSupportMode.All,
                        new System.Net.Security.RemoteCertificateValidationCallback(delegate
                        {
                            return true;
                        }), null, 0, 0, 0, null);
                    Console.WriteLine(client.WelcomeMessage);
                    string remoteCurrentPath = client.GetCurrentDirectory();
                    IList<AlexPilotti.FTPS.Common.DirectoryListItem> list = client.GetDirectoryList(remoteCurrentPath);
                    flag = client.PutFile(Path.Combine(_strSourthDir, fileName), _strDir + Path.GetFileName(fileName));
                   
               Log.Write(string.Format("upload {0} to {1} success!,Transferred bytes count:{2} bytes", fileName, _strDir + Path.GetFileName(fileName),flag.ToString()));
                file.Move(fileName, _strSourthDir, _strBackDir);
                Thread.Sleep(1);

 

转载于:https://www.cnblogs.com/lanniao/archive/2013/05/14/3077728.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值