<p>I have an application running on multiple IIS servers that need to parse a CSV file that is placed on a common network drive.  If I use the <a href="http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.created.aspx" rel="nofollow noreferrer">System.IO.FileSystemWatcher Created event</a> to be notified of the event when the file is available, how can I ensure only one server parses the file?  If all servers are notified of this change, all will try to parse it.  Should the first server copy this locally and then parse it?  Would this cause errors on the other servers? Should I set the remote directory access to only allow one server read access?</p>

<p>The file contains records that needs to be inserted into a shared database, but there is no unique key for the records.  Therefore, if more than one server grabs the file at the same time and inserts the records, there will be duplicates in the database.</p>

Key question is: Does something bad happen when all of them try and parse the file at roughly the same time? Multiple read access is basically allowed on the file system level, so this fact alone would not necessarily break anything.
I would probably try the method of creating a lock file on first file access and make servers look for the lock file before accessing the file. Delete the lock file when you're done.
You could also place an exclusive lock on the file, only one server will be able to do that at a time. The others will fail trying:
```
```
FileStream fs = new FileStream(
  FilePath, 
  FileMode.Open,
  FileAccess.ReadWrite, 
  FileShare.None
);
```
```