/// <summary> /// 下载文件夹所有文件(排除特殊文件夹`.git`, `.svn`, `node_modules`等) /// </summary> /// <param name="localDir">本地路径</param> /// <param name="dir">服务器路径</param> ///<param name="rule">下载规则</param> /// <returns></returns> public List <string> DownloadDirectory(string localDir, string dir, DownLoadRule rule = null) { var lstrules = new List <FtpRule>(); if (rule != null) { if (rule.FtpFileExtension != null && rule.FtpFileExtension.Length > 0) { lstrules.Add(new FtpFileExtensionRule(!rule.IsExclude, rule.FtpFileExtension)); } if (rule.FileSize > 0) { FtpOperator ftpOperator = rule.IsLessThan ? FtpOperator.LessThan : FtpOperator.MoreThan; lstrules.Add(new FtpSizeRule(ftpOperator, rule.FileSize)); } } lstrules.Add(new FtpFolderNameRule(false, FtpFolderNameRule.CommonBlacklistedFolders)); List <string> lst = new List <string>(); var result = ftp.DownloadDirectory(localDir, dir, FtpFolderSyncMode.Update, FtpLocalExists.Skip, FtpVerify.None, lstrules, this.ReturnProgress); foreach (var p in result) { if (p.IsSuccess) { lst.Add(p.LocalPath); } } return(lst); }