Checking a new file every few seconds is actually not so bad, and in fact it is the only portable way to monitor file system changes. If you are working on Linux, answers to a question related to @sdolan will help you check new files more efficiently, but they will not help you with the other part of your question.
Finding that the file is fully copied is much more difficult than at the beginning. Best of all, when a new file is found, wait until it touches for a while before processing it. The duration of the waiting period is determined experimentally. This is a balancing act: the interval is too short, and you run the risk of working with incomplete files; make it too long and the user will notice a delay between the completion of the copy operation and the processing of the code.
source share