title: Copy directories and their contents async
body: <p>I have found <a href="http://msdn.microsoft.com/en-us/library/kztecsys.aspx" rel="nofollow">this solution on MSDN</a> that can copy files from a one directory to another, but it only copies from the main directory  and not the sub-directories.</p>
  
  <p>How can I modify this solution so it will also copy all of the folders and their contents?</p>
  
  <pre><code>string StartDirectory = @"C:\Users\...";
  string EndDirectory = @"C:\Users\....";
  
   //Creates all of the directories and sub-directories
  foreach (string dirPath in Directory.GetDirectories(StartDirectory, "*", SearchOption.AllDirectories))
      Directory.CreateDirectory(dirPath.Replace(StartDirectory, EndDirectory));
  
  foreach (string filename in Directory.EnumerateFiles(StartDirectory))
  {
         using (FileStream SourceStream = File.Open(filename, FileMode.Open))
         {
               using (FileStream DestinationStream = File.Create(EndDirectory + filename.Substring(filename.LastIndexOf('\\'))))
               {
                    await SourceStream.CopyToAsync(DestinationStream);
                }
          }
  }
  </code></pre>