简体   繁体   English

FileWatcher不启动时获取文件更改

[英]get file changes when FileWatcher does not fire

I have aa program (matrkion Data Manager to be exact) that write to a log file up to s curtain size then begins overwriting the log from the beginning. 我有一个程序(准确地说是Matrkion数据管理器),该程序写入最大为S大小的日志文件,然后从头开始覆盖日志。 Not exactly ideal for debugging and event logging. 对于调试和事件记录而言,并不是十分理想。 So I am trying to write a C# program to establish a FileWatcher object so when the log is written to I can get the changes and save them off. 因此,我尝试编写一个C#程序来建立FileWatcher对象,以便在写入日志时可以获取更改并将其保存。 This way I can see the entire log contents. 这样,我可以看到整个日志内容。 The issue is the FileWatcher Change event is never thrown so can know when the log is changed. 问题是永远不会引发FileWatcher Change事件,因此可以知道何时更改日志。 The only thing that is thrown is a FileSizeChange flag when the log is not filled, which it is always filled. 仅在未填充日志时才会抛出FileSizeChange标志,该标志始终会被填充。 Is there another way I can go about this? 我还有其他方法可以解决这个问题吗?

I am going to go ahead and use a timer to poll the log every x seconds. 我将继续使用计时器,每隔x秒轮询一次日志。 Not efficient but it works. 效率不高,但是行得通。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM