dn: CN=FirstName LastName,OU=IT Group,OU=Resources,OU=CompanySite,DC=example,DC=com
changetype: add
accountExpires: 0
businessCategory: iDQC
c: US
cn: FirstName LastName
co: United States
codePage: 0
company: CompanySite
countryCode: 840
department: Information Technology
description: 2/24/2015 10:39:25 AM firstname.lastname logged on to COMPUTERNAME
displayName: FirstName LastName
distinguishedName:
CN=FirstName LastName,OU=IT Group,OU=CompanySite,DC=example,DC=com
division: N/A
dSCorePropagationData: 20160511184301.0Z
dSCorePropagationData: 20160222194509.0Z
dSCorePropagationData: 20150710200320.0Z
dSCorePropagationData: 20140926143022.0Z
dSCorePropagationData: 16010714223649.0Z
.... (hundreds of lines here)
我有一个看起来像这样的LDF文件。
我想检索以下字段
department
telephoneNumber
title
有没有比逐行读取更好的方法呢?
答案 0 :(得分:1)
var foundLines = File.ReadLines(<ldif file>)
.Where(l=>l.StartsWith("department") || l.StartsWith("title") || l.StartsWith("telephoneNumber"));
是一个好的开始,但它不是魔术,它只是读取文件的所有行。