Closed mayermart closed 1 year ago
of course @mayermart you are welcome to submit a PR!
This signature makes more sense to me:
IDirectoryInfo.CopyTo(string` destDirectoryName);
However, something like this would be better in my opinion:
IDirectoryInfo.CopyTo(IDirectoryInfo destination, bool recursive = true);
if you submit a PR please include unit test and also update the readme
For consistency with FileInfo.CopyTo i would stay with a Signature like
IDirectoryInfo.CopyTo(string destDirectoryName, bool recursive = false);
and returning a IDirectoryInfo for the Destination Directory
So you can use it in two lines like
IDirectoryInfo source = fileSystem.DirectoryInfo.FromDirectoryName(sourceDirectoryName);
IDirectoryInfo dest = source.CopyTo(destDirectoryName, recursive: true);
otherwise it would require three lines:
IDirectoryInfo source = fileSystem.DirectoryInfo.FromDirectoryName(sourceDirectoryName);
IDirectoryInfo dest = fileSystem.DirectoryInfo.FromDirectoryName(destDirectoryName);
source.CopyTo(dest , recursive: true);
But as the first line would be creating the dest IDirectoryInfo anyway, it is easy to create an overload, returning the injected IDirectoryInfo.
Also i would set recursive default to false, as this is the behavior of many other tools (e.g. rm, mv, cp on linux bash).
Yeah it all makes sense. Maybe have both overloads so we are both happy :-) but yeah I agree with all the rest.
@gigi81 just in case there was no notification: I created a PR containing a CopyTo Feature: #19 If you got some time, please take a look :)
This is implemented in 2.0.3
Hi,
i would like to implement an Extension Method for recursively copy a Directory based on https://docs.microsoft.com/de-de/dotnet/standard/io/how-to-copy-directories
Would it be helpful to create a Pull request and add it to this Package? And if so, should it be implemented as IDirectoryInfo.CopyTo(string destDirectoryName) (as it already exits in FileInfo.CopyTo) or better as IDirectory.CopyDirectory(string sourceDir, string destinationDir, [options]), or both?
Thanks Martin