I am monitoring a text file that is being written to by a server program. Every time the file is changed the content will be outputted to a window in my program.
The problem is that I can't use the Streamreader
on the file as it is being used by another process
. Setting up a Filestream
with ReadWrite
won't do any good since I cannot control the process that is using the file.
I can open the file in notepad. It must be possible to access it even though the server is using it.
Is there a good way around this?
Should I do the following?
- Monitor the file
- Make a temp copy of it when it changes
- Read the temp copy
- Delete the temp copy.
I need to get the text in the file whenever the server changes it.