title: Having a issue processing multiple files at once in a Windows Service with a FileSystemWatcher
body: <p>When I try and process more than a couple of files at the same time (they are created and dumped in a folder at the same time), my service dies.</p>
  
  <p>When I wasn't trying to use a thread and had all the processing (where the code in the ProcessFiles method now is) in the Watcher_Created event, at least one file gets through successfully.</p>
  
  <p>When I added the threading (which I'm pretty sure I have to do for this, but am totally unsure of the exact flow and syntax using the threading), I get the following msg in my ProcessFiles method:</p>
  
  <p>System.ArgumentException: Empty path name is not legal.
     at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)</p>
  
  <p>The above msg occurs on the using line:</p>
  
  <pre><code>private static void ProcessFiles()
          {
              try
              {
  Thread.Sleep(500);
  
  GetCruiseLineShipName(fullFileName, ref cruiseLine, ref shipName);
  using (StreamReader sr = new StreamReader(File.Open(fullFileName, FileMode.Open, FileAccess.Read, FileShare.Read)))
  </code></pre>
  
  <p>which is obvious, because the "fullFileName" is an empty string. However, it does get set in the Watcher_Created event:</p>
  
  <pre><code>private static void Watcher_Created(object sender, FileSystemEventArgs e)
          {
              fullFileName = e.FullPath;
          }
  </code></pre>
  
  <p>So, I don't understand why the fullFileName variable is an empty string. I know it must have something to do with the threading I'm trying.</p>
  
  <p>My OnStart event looks like this:</p>
  
  <pre><code>protected override void OnStart(string[] args)
          {
              FileSystemWatcher Watcher = new FileSystemWatcher(@"C:\DropOff_FTP\MIS");
  
              Watcher.EnableRaisingEvents = true;
              Watcher.Created += new FileSystemEventHandler(Watcher_Created);
              Watcher.Filter = "*.txt";
              Watcher.IncludeSubdirectories = false;
              Watcher.InternalBufferSize = 64;
  
              Thread t = new Thread(new ThreadStart(ProcessFiles));
              t.Start();
          }
  </code></pre>
  
  <p>Can someone PLEASE inform me how I can use the FileSystemWatcher to process multiple files that are dumped in there at the same time. If I need to use threading, could you please supply how I would use the thread based on the code above?</p>
  
  <p>btw, I'm using the 4.0 framework.</p>