There are several ways to read information from a file. At the same time, if the file is occupied by another process, an exception will be thrown.
The exception can of course be caught, but if this is unacceptable, what can be done?
The situation is this: using FileSystemWatcher
to read the file after the change, the change will most likely be made from notepad. If immediately after the change event you try to read the file, then the notepad process will still use it and it will not have time to release access, we will get an exception in most cases.
For a start, I would like to understand how you can check the availability of a file reading before reading it, so as not to catch the exception.