Sadly there is no built-in function in System.IO that will copy a folder and its contents.  Following is a simple recursive algorithm that copies a folder, its sub-folders and files, creating the destination folder if needed.  For simplicity, there is no error handling; an exception will throw if anything goes wrong, such as null or invalid paths or if the destination files already exist.

ASP.NET Web Hosting – 3 Months Free and Free Setup

using System;
using System.IO;

namespace CSharp411
{
    class Program
    {
        static void Main( string[] args )
        {
            CopyFolder( @"C:\temp\test", @"C:\temp\out" );
            Console.ReadLine();
        }
        static public void CopyFolder( string sourceFolder, string destFolder )
        {
            if (!Directory.Exists( destFolder ))
                Directory.CreateDirectory( destFolder );
            string[] files = Directory.GetFiles( sourceFolder );
            foreach (string file in files)
            {
                string name = Path.GetFileName( file );
                string dest = Path.Combine( destFolder, name );
                File.Copy( file, dest );
            }
            string[] folders = Directory.GetDirectories( sourceFolder );
            foreach (string folder in folders)
            {
                string name = Path.GetFileName( folder );
                string dest = Path.Combine( destFolder, name );
                CopyFolder( folder, dest );
            }
        }
    }
}

Related posts:

  1. Check Valid File Path in C#
  2. C# Read Text File Line-by-Line
  3. Truncate File Path with Ellipsis
  4. Embedded Image Resources
  5. C# Read Text File into String