public static void EqualStructure(IDirectoryObject source, IDirectoryObject target) { var sourceFiles = source.GetFiles().ToList(); var targetFiles = target.GetFiles().ToList(); foreach (var sourceFile in sourceFiles) { Assert.IsTrue(targetFiles.Any(t => t.Name == sourceFile.Name)); } var subDirectories = source.GetDirectories(); foreach (var sourceSubDir in subDirectories) { var targetSubDir = target.GetDirectory(sourceSubDir.Name); Assert.IsTrue(targetSubDir.Exists); EqualStructure(sourceSubDir, targetSubDir); } }
private List <IFileObject> GetFilesToCopy(IDirectoryObject source, IDirectoryObject target) { var filesToUpload = new List <IFileObject>(); var sourceFiles = source.GetFiles(); foreach (var sourceFile in sourceFiles) { var targetFile = target.GetFile(sourceFile.Name); if (!targetFile.Exists || sourceFile.ModifiedDate >= targetFile.ModifiedDate) { filesToUpload.Add(sourceFile); } } var subDirectories = source.GetDirectories(); foreach (var sourceSubDirectory in subDirectories) { var targetSubDirectory = target.GetDirectory(sourceSubDirectory.Name); filesToUpload.AddRange(GetFilesToCopy(sourceSubDirectory, targetSubDirectory)); } return(filesToUpload); }