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 System.IO.FileSystemWatcher Created event 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?
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.