title: Copying Directory Not Letting Go Of Files
body: <p>I got this code straight from <a href="http://msdn.microsoft.com/en-us/library/cc148994.aspx" rel="nofollow">How to: Copy, Delete, and Move Files and Folders (C# Programming Guide)</a>:</p>
  
  <pre><code>string sourceDir = currDir + "\\" + "Trends";
  string targetDir = currDir + "\\" + reportDir + "\\" + "Trends";
  if (Directory.Exists(sourceDir))
  {
      string[] files = Directory.GetFiles(sourceDir);
  
      foreach (string file in files)
      {
          string fileName = Path.GetFileName(file);
          string targetFile = Path.Combine(targetDir, fileName);
          File.Copy(file, targetFile, true);
      }
  }
  </code></pre>
  
  <p>However, when I run this code I throw an error on every file in sourceDir that it can't be accessed because it is already in use.  When I exit the code it is clear that no other processes are using these files so it must be this block of code that is causing the problem.  Is there a way to use "using" for this?</p>
  
  <p>Any advice is appreciated.</p>
  
  <p>Regards.</p>