我尝试使用Directory.Getfiles
,但它不会获取目录中的所有文件。文件为 .txt 格式这是我的代码Form_Load
:
Public SourceDir As String = Application.StartupPath & "\Source\"
If Not Directory.Exists(SourceDir) Then
Directory.CreateDirectory(SourceDir)
End If
Dim Files() As String = Directory.GetFiles(SourceDir )
For Each File In Files
Dim Lines() As String
Dim StockList As List(Of ListViewItem) = New List(Of ListViewItem)
Dim StockItem As ListViewItem
MsgBox(File)
Lines = IO.File.ReadAllText(File).Split(New String() {ControlChars.CrLf}, StringSplitOptions.RemoveEmptyEntries)
For j = 0 To Lines.Length - 1 Step 8
StockItem = New ListViewItem(Lines(j))
StockItem.SubItems.Add(Lines(j + 1))
StockItem.SubItems.Add(Lines(j + 2))
StockItem.SubItems.Add(Lines(j + 3))
StockItem.SubItems.Add(Lines(j + 4))
StockItem.SubItems.Add(Lines(j + 5))
StockItem.SubItems.Add(Lines(j + 6))
StockItem.SubItems.Add(Lines(j + 7))
listHouse.Items.Add(StockItem)
Next
Next
它只显示其中一个文件,仅此而已!