[fpc-pascal] Avoiding File conflicts

James Richters james.richters at productionautomation.net
Mon Jan 4 03:18:50 CET 2021


I am checking for the existence of a file in my main program loop that runs about 4 times a second waiting for keystrokes etc...
If I see the file exists, I just want to open the file, read it into a buffer and process it.  

This works most of the time, but every once in a while I get
EInOutError: Access denied with a return code of 217 

I suspect that I happen to see the file is there and try to read it before the program that created the file is done writing it.
What is the proper way to detect the file is in use so I don't bother trying to open it until it's done being written?

I'm on a windows system if that makes any difference and this is a console program.

James




More information about the fpc-pascal mailing list