I am making a program in C# with a lot of IO operations. Some of that operations are copying directories.
I was really stunned when I figured out that you don't have something like Directory.copy(SourceDir, DestinationDir) in C#.
I googled a little bit around and at msdn they give a code sample to copy directories. (http://msdn.microsoft.com/en-us/library/bb762914.aspx). But when you search a little bit further, there is a Directory.Copy method in the Microsoft.VisualBasic.FileIO namespace. (http://msdn.microsoft.com/en-us/library/ms127957.aspx)
I could refere to this namespace and use this method, but there must be a reason why Microsoft does not support this in C# and why they aren't mentioning it on msdn.
Hope somebody can tell me the reason.
I can write extensionmethod to solve this problem & I can solve it pretty easy, but my question is Why? Why is there no such method in C#, I just want to know :-)
Alternatively, right-click the folder, select Show more options and then Copy. In Windows 10 and earlier versions, right-click the folder and select Copy, or click Edit and then Copy. Navigate to the location where you want to place the folder and all its contents.
If you specify the -L option, docker cp follows any symbolic link in the SRC_PATH . docker cp does not create parent directories for DEST_PATH if they do not exist. Error condition: the destination directory must exist.
Because it's easy enough to do a foreach
on a DirectoryInfo.GetFiles()
, while also giving you an opportunity to filter the list of files being copied, or do some other operation besides copying.
If it really bothers you, write an extension method for the DirectoryInfo
class, or a FileInfo[]
collection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With