请教老师:我想把一个文本文件的内容转为集合,在命令窗口输入以下代码
Dim sjfilename = "d:\LSconfig.ini"
Dim jihe As new List (of String)
jihe.AddRange(FileSys.ReadAllText(sjfilename,Encoding.Default).Split("vbcrlf"))
Dim str As String = FileSys.ReadAllText(sjfilename)
Output.Show("-----文本文件的原值------------------------------------")
Output.Show(str)
Output.Show("-----应为21 现在为7 --------------------------------")
Output.Show("-----转为集合后的集合数--------------------------------")
Output.Show(jihe.count)
Output.Show("-------------------------------------------------------")
Output.Show("-----显示集合中的每个值--------------------------------")
For Each jh As String In jihe
Output.Show(jh)
Next
Output.Show("-----把 v 当回车换行符了------------------------------")
运行后的结果如下
-----文本文件的原值------------------------------------
zsjk_Name|fjzhywglsjk
zsjk_User|fjuser_foxtable
zsjk_Pass|fjuser_22431_foxtable_201506
zsjk_n_IP|10.211.91.30
zsjk_y_IP|61.178.243.57
zsjk_IP|10.211.91.30
_ServerIp|127.0.0.1
_ServerPort|52178
_HeartbeatInterval|30
_HeartbeatTimeout|100
_ServerIp_t|
10.211.91.30
_ServerPort_t|52177
_HeartbeatInterval_t|30
_HeartbeatTimeout_t|100
_Oldsystemtime|2017-06-29 17:21:17
_Newsystemtime|2017-06-30 08:27:24
_UpdatePath|\system
_FTPHost|10.211.91.30
_FTPAccount|UpDate
_FTPassword|123
_FTPPort|21
-----应为21 现在为7 --------------------------------
-----转为集合后的集合数--------------------------------
7
-------------------------------------------------------
-----显示集合中的每个值--------------------------------
zsjk_Name|fjzhywglsjk
zsjk_User|fjuser_foxtable
zsjk_Pass|fjuser_22431_foxtable_201506
zsjk_n_IP|10.211.91.30
zsjk_y_IP|61.178.243.57
zsjk_IP|10.211.91.30
_Ser
erIp|127.0.0.1
_Ser
erPort|52178
_HeartbeatInter
al|30
_HeartbeatTimeout|100
_Ser
erIp_t|
10.211.91.30
_Ser
erPort_t|52177
_HeartbeatInter
al_t|30
_HeartbeatTimeout_t|100
_Oldsystemtime|2017-06-29 17:21:17
_Newsystemtime|2017-06-30 08:27:24
_UpdatePath|\system
_FTPHost|10.211.91.30
_FTPAccount|UpDate
_FTPassword|123
_FTPPort|21
-----把 v 当回车换行符了------------------------------