|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Looping through directoriesI 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. On Sun, 2 Jul 2006 15:12:01 -0700, Mark
<M***@discussions.microsoft.com> wrote: >I am trying to loop through 2 separate directories (using the Dir) at the This example gets all the files in each of two directories and>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. 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 Mark wrote:
> I am trying to loop through 2 separate directories (using the Dir) at the Dir uses an internal "pointer" to keep track of where it is within the > same time but it seems to get confused and is mixing the files from both > directories. current directory. You /can't/ "scan" two directories (or sub-directories) at the same time. Read up on the Directory class, particularly the GetFiles method(s). For Each sFile As String _ In Directory.GetFiles( "path", "*.*" ) Debug.WriteLine( sFile ) Next HTH, Phill W.
WebBrowser1.DocumentText
Multithreaded Updating of StatusBar HTML edit Vb.net how to delete a file when the windows start problem with string function in vb.net XML or SQL Server? programmically open a pdf file in vb.net Font size not right when converting from RTF to Web DLL in VB.NET Publishing An ASP.NET Website With Visual Studio .NET 2005 |
|||||||||||||||||||||||