1

I need to read a log file that is currently in use in order to monitor it for changes in length. I’d like to find the length of the log file when I click a button then when the length increases I’d like to know this and scan each line after the increase in length. The line count will be displayed in a label so I can see the line count change.

Tried using ReadAllLines however this wasn’t sufficient as the ‘application is currently in use’.

Jack
  • 41
  • 4
  • 3
    [How can I read a file even when getting an "in use by another process" exception?](https://stackoverflow.com/q/4400517/87698) – Heinzi Apr 12 '23 at 10:48
  • 1
    I would recommend using [FileSystemWatcher](https://learn.microsoft.com/en-us/dotnet/api/system.io.filesystemwatcher?view=net-7.0) to monitor file for changes rather than actively poll it. – orhtej2 Apr 12 '23 at 10:55
  • 3
    I would consider using some type of logging system that can do things like sending messages to some remote service whenever there is any logging. I would expect that to be much more reliable than monitoring files. – JonasH Apr 12 '23 at 11:04

0 Answers0