public bool UploadDirectory(string directory, string destination) { if (directory[directory.Length - 1] != Path.DirectorySeparatorChar) { directory += Path.DirectorySeparatorChar; } var fileList = FileList.Build(new Configuration.SourceDirectory() { Directory = directory }); var logger = Logger.Global; Parallel.ForEach(fileList.Files, new ParallelOptions() { MaxDegreeOfParallelism = Threads }, f => { var relPath = directory.RelativePath(f.Path).Replace('\\', '/'); var relPathDir = directory.RelativePath(Path.GetDirectoryName(f.Path)).Replace('\\', '/'); CreateDirectory(FtpDirectoryEntry.Combine(destination, relPathDir), true); logger.Write($"Uploading file {relPath}."); UploadFile(f.Path, FtpDirectoryEntry.Combine(destination, relPath)); }); return(false); }