我有一个文本文件,每次从服务器数据中获取更新。现在根据我的要求,我必须逐行读取此文件。我知道如何读取文件行通过线,但没有得到如何看它continuously.Here是我的C#代码逐行读取文件中的行...如何连续读取文本文件
if (System.IO.File.Exists(FileToCopy) == true)
{
using (StreamReader reader = new StreamReader(FileToCopy))
{
string line;
string rawcdr;
while ((line = reader.ReadLine()) != null)
{
//Do Processing
}
}
}
按我的要求我必须不断地观看文本文件changes.Suppose新行已被添加到文本文件中,添加它的那一刻应该被上面定义的代码读取,并且处理应该根据条件来执行。
作为参考,UNIX实用程序['尾-f'](http://stackoverflow.com/questions/1439799/how-can-i-get-the-source-code-for-the- linux-utility-tail)实现了这一点。他们称之为“跟随”一个文件。 –
[c#不断读取文件]的可能重复(http://stackoverflow.com/questions/3791103/c-sharp-continuously-read-file) –