如何读出文件的里面的值
INI文件如下[武松打你]
RoseName="1a"
ServerName=【bbb】
UserName=tglfjxsj0164
PassWord=dddd
StartTime=2013/1/21 0:14:51
Remark2=0
[武松打他]
RoseName="2b"
ServerName=【bbbb】
UserName=tglfjxsj0165
PassWord=dddd
StartTime=2013/1/21 0:14:51
Remark2=1
[武松打男]
RoseName="3c"
ServerName=【bbb】
UserName=tglfjxsj0166
PassWord=dddd
StartTime=2222/2/22 2:22:22
Remark2=0
[武松打你11]
RoseName="1a"
ServerName=【bbb】
UserName=tglfjxsj0164
PassWord=dddd
StartTime=2222/2/22 2:22:22
Remark2=0
[武松打他22]
RoseName="2b"
ServerName=【bbbb】
UserName=tglfjxsj0165
PassWord=dddd
StartTime=2222/2/22 2:22:22
Remark2=1
[武松打男33]
RoseName="3c"
ServerName=【bbb】
UserName=tglfjxsj0166
PassWord=dddd
StartTime=2222/2/22 2:22:22
Remark2=1
代码如下
Function aaabbb() As String
Dim str As String = File.ReadAllText("C:\Users\admin\Desktop\test1.ini", System.Text.Encoding.[Default])
Dim ary As Array = Regex.Matches(str, "(?is)\[([^]\s]+)\]\s*RoseName=" + """([^""\s]+)""" + "\s*ServerName=【([^】\s]+)】\s*UserName=([a-z0-9_]+)\s*PassWord=(\S+)\s*StartTime=(\S+(\s*\S+)?)\s*Remark2=(\d+)").OfType(Of Match)().[Select](Function(t) New With { _
Key .name = t.Groups(1).Value, _
Key .RoseName = t.Groups(2).Value, _
Key .ServerName = t.Groups(3).Value, _
Key .UserName = t.Groups(4).Value, _
Key .PassWord = t.Groups(5).Value, _
Key .StartTime = Convert.ToDateTime(t.Groups(6).Value), _
Key .Remark2 = Convert.ToInt32(t.Groups(8).Value) _
}).Where(Function(t) t.StartTime > DateTime.Now And t.Remark2 = 0).ToArray()
'Return 输出name RoseName ServerName 等 这些值如何读出来
End Function
补充:.NET技术 , VB.NET