C#: tail like program for text file

前端 未结 4 805
后悔当初
后悔当初 2020-12-30 11:18

I have a log file that continually logs short lines. I need to develop a service that reacts (or polls, or listens to) to new lines added to that file, a sort of unix\' tail

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-30 11:52

    It is important to note that Microsoft (since vista/svr08) no longer updates file metadata when a file is updated (such as a log file being updated by a service).

    For example, the metadata for a file such as modified date, will not be updated until the file is closed by the service/program which is updating the log file.

    Therefore FileSystemWatcher will NOT catch log file updates as you might expect.

    https://blogs.technet.microsoft.com/asiasupp/2010/12/14/file-date-modified-property-are-not-updating-while-modifying-a-file-without-closing-it/

提交回复
热议问题