小编nuk*_*eos的帖子

c#在txt文件中搜索字符串

我想在txt文件中找到一个字符串,如果字符串比较,它应该继续读取行,直到我用作参数的另一个字符串.

例:

CustomerEN //search for this string
...
some text wich has details about customer
id "123456"
username "rootuser"
...
CustomerCh //get text till this string
Run Code Online (Sandbox Code Playgroud)

我需要细节与他们合作.

我正在使用linq来搜索"CustomerEN",如下所示:

File.ReadLines(pathToTextFile).Any(line => line.Contains("CustomerEN"))
Run Code Online (Sandbox Code Playgroud)

但现在我仍然坚持阅读行(数据)直到"CustomerCh"来提取细节.

c#

17
推荐指数
2
解决办法
11万
查看次数

标签 统计

c# ×1