private static IEnumerable <string> DownloadFiles(string localPath, IFtpClient client, string directoryFullPath, DateTime beginTime) { if (!Directory.Exists(localPath)) { Directory.CreateDirectory(localPath); } var localFiles = new DirectoryInfo(localPath).GetFiles("*.*"); var remoteFiles = client.GetListing(directoryFullPath).Where(p => p.Modified >= beginTime); var downloads = new List <string>(); var localFullPaths = new List <string>(); foreach (var remoteFile in remoteFiles) { if (remoteFile.Size <= 0) { continue; } if (localFiles.Any(p => p.Name == remoteFile.Name)) { var localFile = localFiles.Single(p => p.Name == remoteFile.Name); if (localFile.Length == remoteFile.Size) { continue; } } downloads.Add(remoteFile.FullName); localFullPaths.Add(Path.Combine(localPath, remoteFile.Name)); } client.DownloadFiles(localPath, downloads); Console.WriteLine($"Download {downloads.Count} records from {directoryFullPath}..."); return(localFullPaths); }