Skip to content

Commit 63f5c5a

Browse files
feat: add new copyto method
1 parent 0880def commit 63f5c5a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/WouterVanRanst.Utils/Extensions/FileInfoExtensions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ public static FileInfo CopyTo(this FileInfo source, DirectoryInfo targetDir)
1515
return source.CopyTo(Path.Combine(targetDir.FullName, source.Name));
1616
}
1717

18+
/// <summary>
19+
/// Copy file to the same directory with a new name.
20+
/// </summary>
21+
/// <param name="source"></param>
22+
/// <param name="name"></param>
23+
/// <returns></returns>
24+
public static FileInfo CopyTo(this FileInfo source, string name)
25+
{
26+
var targetPath = Path.Combine(source.DirectoryName, name);
27+
return source.CopyTo(targetPath);
28+
}
29+
1830
/// <summary>
1931
/// Copy file to the target directory with the given name.
2032
/// </summary>

0 commit comments

Comments
 (0)