in reply to Check if file is written by other process
Another possibility, if you control the file writing process, would be to create a second (empty) file having the role of a flag. Create the flag before opening the file for writing, and remove the flag once writing the file is completed. Then you only need to check for the existence of the flag.
Update: When i wrote the above 15 minutes ago, I forgot another possibility, despite the fact that I am using it regularly at work. We are using the flag system described above when we want to know that the writing process has completed all the files that it is supposed to write.
When a file by file check is needed, the solution is even easier: the writing process writes a file with a temporary name (e.g. a .tmp extension) and renames it to its final name once it has completed the task. For example, the writing process write an output.tmp file. Once the file is complete, it renames it as output.txt. Your process then only needs to poll for *.txt files.
|
|---|