Testing for an open file
I have an application that appends a log to a CSV file as each instance of
the application ends. The CSV is used by others on an infrequent basis to
check on the log. The CSV file sits on a shared server/directory for this
purpose.
Usually the coincidence of the application ending and the CSV being open is
very rare (never happended in 18 months -so far!). The problem arises when
the CSV is left open as recently happended in this case the application
failed as it couild not write to the CSV file. My application needs to
detect this, issue a warning and wait for the CSV to be released or store
the log locally and append it next time the application is run.
How can I detect if a CSV is open and therefore not available to be updated?
Also is it possible to identify the user who has the file open, in a similar
way that Excel warns if an Excel Workbook is open?
--
Cheers
Nigel
|