/// <summary> /// Recursively copies the source directory and all its content to the /// specified target directory. /// </summary> /// <param name="sourcePath">The source directory to copy.</param> /// <param name="targetPath">The destination path.</param> public void CopyDirectory(string sourcePath, string targetPath) { EnsureDirectory(targetPath); foreach (string sourceFile in GetFiles(sourcePath)) { string targetFile = PathBuilder.Combine(targetPath, Path.GetFileName(sourceFile)); CopyFile(sourceFile, targetFile, CopyOption.Overwrite); } foreach (string directory in GetDirectories(sourcePath)) { CopyDirectory(directory, targetPath); } }
public void Can_combine_two_drive_paths() { Assert.AreEqual(@"d:\dir1\dir2\", _pathBuilder.Combine(@"d:\dir1\", @"\dir2\")); }