我希望在一个txt文件中查找字符串。如果匹配到了这个字符串,它应该继续读取行,直到另一个我用作参数的字符串出现。
例如:
例如:
CustomerEN //search for this string
...
some text which has details about the customer
id "123456"
username "rootuser"
...
CustomerCh //get text till this string
否则,我需要详细了解它们的细节。
我正在使用 LINQ 来搜索“CustomerEN”,如下所示:
File.ReadLines(pathToTextFile).Any(line => line.Contains("CustomerEN"))
但现在我只能阅读行(数据),直到“CustomerCh”以提取详细信息。