On Sun, 2 Jul 2006 15:12:01 -0700, Mark
<Ma**@discussions.microsoft.comwrote:
>I am trying to loop through 2 separate directories (using the Dir) at the
same time but it seems to get confused and is mixing the files from both
directories. I tried to use the My.Computer.Get files method but I can't get
it to work other than in the myDocuments directory. It also returns the full
path when I only wnat the file name.
This example gets all the files in each of two directories and
populates two list boxes with the respective filenames:
Imports System.IO
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim dir1 As New DirectoryInfo("C:\Windows")
Dim FoundFiles1 As FileInfo() = dir1.GetFiles()
Dim fiTemp As FileInfo
For Each fiTemp In FoundFiles1
Me.ListBox1.Items.Add(fiTemp)
Next fiTemp
Dim dir2 As New DirectoryInfo("C:\Windows\System32")
Dim FoundFiles2 As FileInfo() = dir2.GetFiles()
For Each fiTemp In FoundFiles2
Me.ListBox2.Items.Add(fiTemp)
Next fiTemp
End Sub
Gene