title: C# using filestream instead of file.copy
body: <p>I am using File.copy to copy some files.
  The problem is, it copies files asynchronus so it continues the program while still copying some files.</p>
  
  <p>Now i got the tip to use filestream instead of file.copy.</p>
  
  <p>The code i use now is: (example)</p>
  
  <pre><code>            string instdir = (@"C:\test.dll");
              string srcdir = @"C:\test1.dll";
              File.Copy(srcdir, instdir, true);
  </code></pre>
  
  <p>The problem with this is, the "test.dll" value is read from a xml file (so there are much more files to copy)
  After the copy it should execute an .exe file, but it executes the file before everything is copied and that is giving the error.</p>
  
  <p>Any tips?</p>
  
  <p>I also have the next question:</p>
  
  <p>I got a solution for above, this is a single file copy.</p>
  
  <p>Now i also have this one: </p>
  
  <pre><code>public static void CopyFolder(DirectoryInfo source, DirectoryInfo install)
          {
              foreach (DirectoryInfo dir in source.GetDirectories())
                  CopyFolder(dir, install.CreateSubdirectory(dir.Name));
              foreach (FileInfo file in source.GetFiles())
                  file.CopyTo(Path.Combine(install.FullName, file.Name), true);
          }
  </code></pre>
  
  <p>for multi file copy (copy everything in folder)</p>
  
  <p>Any idea how to use it in that?</p>
  
  <p>Thanks!</p>