Best way to copy the entire contents of a directory in C#

Posted by Keith on Stack Overflow See other posts from Stack Overflow or by Keith
Published on 2008-09-12T11:38:52Z Indexed on 2010/03/27 0:53 UTC
Read the original article Hit count: 329

Filed under:
|
|

I want to copy the entire contents of a directory from one location to another in C#.

There doesn't appear to be a way to do this using System.IO classes without lots of recursion.

There is a method in VB that we can use if we add a reference to Microsoft.VisualBasic:

new Microsoft.VisualBasic.Devices.Computer().
    FileSystem.CopyDirectory( sourceFolder, outputFolder );

This seems like a rather ugly hack. Is there a better way?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET