title: How can I reliably move files (asynchronously) from a directory as they're being created?
body: <p>In my Windows Service solution have a <code>FileSystemWatcher</code> monitoring a directory tree for new files, and whenever it fires a <code>Created</code> event I am trying to move the files asynchronously to another server for further processing.  Here's the code:</p>
  
  <pre><code>foreach (string fullFilePath in 
                  Directory.EnumerateFiles(directoryToWatch, "*.*",  
                                           SearchOption.AllDirectories)
                           .Where(filename =&gt; fileTypes.Contains(Path.GetExtension(filename))))
              {
                  string filename = Path.GetFileName(fullFilePath);
                  using (FileStream sourceStream = File.Open(filename, FileMode.Open, FileAccess.Read))
                  {
                      using (FileStream destStream = File.Create(Path.Combine(destination, filename)))
                      {
                          await sourceStream.CopyToAsync(destStream);
                      }
                  }
              }
  </code></pre>
  
  <p>The problem is that as these files are being copied into the folder I'm watching, they're not always unlocked and available to me.  I want to "retry" when I hit a locked file, but I'm not accustomed to thinking asynchronously, so I have no idea how to put the error'ed file back in the queue.</p>