简体   繁体   English

如何检查并复制.txt文件中新添加的内容

[英]How to check and copy for newly added content in a .txt file

I need to create a file watcher which will look up a newly added file in directory for newly added data. 我需要创建一个文件监视程序,它将在目录中查找新添加的文件以获取新添加的数据。

When ever new data is adding to a .jrn file.The newly added data should copy to a temporary file. 当新数据添加到.jrn文件中时。新添加的数据应复制到一个临时文件中。 I am using window service ( C# ) to develop this. 我正在使用窗口服务( C# )开发它。

I solved this by following the below steps: 我通过以下步骤解决了这个问题:

  1. Create a timer in order to check any new file created 创建一个计时器以检查创建的任何新文件
  2. Use the substring method to get new added content 使用substring方法获取新添加的内容
  3. Swap the last added two contents 交换最后添加的两个内容

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

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