【发布时间】:2013-11-19 21:17:04
【问题描述】:
我目前正在使用以下方法将目录中所有文本文件的内容读入数组中
Dim allLines() As String = File.ReadAllLines(txtfi.FullName)
在文本文件中只有 6 行,它们都遵循相同的格式,并且会读到类似
前色=黑色
我正在尝试搜索单词“forecolour”并检索“=”符号(黑色)之后的信息,以便我可以填充以下代码
AllDetail(numfiles).uPath = ' this needs to be the above result
我只发布了部分代码,但如果有帮助,我可以发布其余部分。如果可能的话,我只需要一点指导
谢谢
这是完整的代码
Dim numfiles As Integer
ReDim AllDetail(0 To 0)
numfiles = 0
lb1.Items.Clear()
Dim lynxin As New IO.DirectoryInfo(zMailbox)
lb1.Items.Clear()
For Each txtfi In lynxin.GetFiles("*.txt")
Dim allLines() As String = File.ReadAllLines(txtfi.FullName)
ReDim Preserve AllDetail(0 To numfiles)
AllDetail(numfiles).uPath = 'Needs to be populated
AllDetail(numfiles).uName = 'Needs to be populated
AllDetail(numfiles).uCode = 'Needs to be populated
AllDetail(numfiles).uOps = 'Needs to be populated
lb1.Items.Add(IO.Path.GetFileNameWithoutExtension(txtfi.Name))
numfiles = numfiles + 1
Next
End Sub
AllDetail(numfiles).uPath = Would be the actual file path
AllDetail(numfiles).uName = Would be the detail after “unitname=”
AllDetail(numfiles).uCode = Would be the detail after “unitcode=”
AllDetail(numfiles).uOps = Would be the detail after “operation=”
在正在读取的文本文件中会有以下几行
Unitname=
Unitcode=
Operation=
Requirements=
Dateplanned=
对于这个数组,我只需要单元名称、单元代码和操作。展望未来,我将需要 dateplanned,因为当它工作时,我想尝试弄清楚如何仅在 dateplanned 与 datepicker 中的日期匹配时才显示信息。希望能得到帮助和任何指导或提示
【问题讨论】:
-
我不确定我是否理解您的问题。不清楚
标签: vb.net winforms visual-studio-2012