Example #1
0
        public static void FtpUploadDirectoryRecursively(string directory, string hostRoot)
        {
            Logger.Info($"Uploading directory '{directory}' to '{hostRoot}'...");

            var files = PathConstruction.GlobFiles(directory, "**/*").ToList();

            for (var index = 0; index < files.Count; index++)
            {
                var file         = files[index];
                var relativePath = PathConstruction.GetRelativePath(directory, file);
                var hostPath     = $"{hostRoot}/{relativePath}";

                FtpUploadFileInternal(file, hostPath, $"[{index + 1}/{files.Count}] ");
            }
        }
Example #2
0
        private static void CopyRecursivelyInternal(string source, string target, FileExistsPolicy policy)
        {
            string GetDestinationPath(string path)
            => Path.Combine(target, PathConstruction.GetRelativePath(source, path));

            Directory.CreateDirectory(target);
            Directory.GetDirectories(source).ForEach(x => CopyRecursivelyInternal(x, GetDestinationPath(x), policy));

            foreach (var sourceFile in Directory.GetFiles(source))
            {
                var targetFile = GetDestinationPath(sourceFile);
                if (!ShouldCopyFile(sourceFile, targetFile, policy))
                {
                    continue;
                }

                //EnsureFileAttributes(sourceFile);
                File.Copy(sourceFile, targetFile, overwrite: true);
            }
        }