This post will discuss how to synchronously copy the entire contents of a directory to another location in C#.

The DirectoryInfo Class provides instance methods for common I/O operations like creating, copying, moving, renaming, and deleting directories. The following example, taken from MSDN, demonstrates how to copy a directory and its contents to a new location.

Download Code

 
The following example from MSDN, copies subdirectories by setting the recursive parameter of the CopyDirectory() method to true. The solution recursively copies each subdirectory, until all subdirectories are processed.

Download Code

That’s all about synchronously copying the entire contents of a directory to another location in C#.