<p><br>
On Jul 13, 2012 4:40 PM, "OlaOst" <<a href="mailto:olaa81@gmail.com">olaa81@gmail.com</a>> wrote:<br>
><br>
> I'm working on a program (using dmd 2.059 under windows) that automatically reloads the contents of a file if it has changed, by checking the last modified timestamp on the file every 0.2 seconds, then using the readText function in std.file to read in the file contents.<br>

><br>
> It works pretty well, but every once in a while I get a "The process cannot access the file because it is in use by another process" error message. I guess this happens when my D program tries to read the file before the text editor manages to close its handle on the file.<br>

><br>
> This would be fair enough if I was writing to the file in my D program, but I only want to read from it. Is this a bug or is there a better way to get file contents in D?</p>
<p>While the text editor is writing the file reading it is a silly thing to do (no one knows what's there).  I'm not familiar with windows but locking under Linux works as so.  Any number or processes can have a read lock but if there is a write lock only the single process can access that file.</p>

<p>Also isn't there something like inotify on windows?  Polling sounds like the wrong solution.</p>