public static CopyDirectories ( string sourceDir, string targetDir, bool includeSubDirectories = false, bool includeRoot = false ) : void | ||
sourceDir | string | full path source directory |
targetDir | string | full path target directory |
includeSubDirectories | bool | if true, all subdirectories and contents will be copied |
includeRoot | bool | if true, the source directory will be created too |
return | void |
public static void CopyDirectories(string sourceDir, string targetDir,
bool includeSubDirectories = false, bool includeRoot = false)
{
var source = new DirectoryInfo(sourceDir);
var target = new DirectoryInfo(targetDir);
DirectoryInfo workingTarget = target;
if (includeRoot)
workingTarget = Directory.CreateDirectory(target.FullName);
CopyContents(source, workingTarget, includeSubDirectories);
}