Drilling down through directories

  • Thread starter Thread starter Jack Russell
  • Start date Start date
J

Jack Russell

I need to drill down from a directory through all the sub directories
and build up a list of files. I have VB6 code to do this but it uses
APIs etc and am hoping that there is a better way of doing in .net 2003

I would appreciate any help or examples that anyone can give me

Thanks

Jack Russell
 
Jack said:
I need to drill down from a directory through all the sub directories
and build up a list of files. I have VB6 code to do this but it uses
APIs etc and am hoping that there is a better way of doing in .net 2003

I would appreciate any help or examples that anyone can give me

Thanks

Jack Russell
Its ok I found getdirectories!
 
Jack Russell said:
Its ok I found getdirectories!

I did this as an enumerator, so I could just do:

for each file in new DirEnumerator("C:\")

I can't remember the exact details but I could dig it up if you are
interested.

Michael
 
Michael said:
I did this as an enumerator, so I could just do:

for each file in new DirEnumerator("C:\")

I can't remember the exact details but I could dig it up if you are
interested.

Michael
Thanks but I have nearly finished

Jack
 
Jack,

Here is some code that you might be able to modify for your needs:

'Be sure to have an Imports System.IO statement in the class that contains
this code

Private Sub DisplayFolderInfo(ByVal folder As String)

Dim di As New DirectoryInfo(folder)
Dim fi As FileInfo

MsgBox("Folder: " & folder)

For Each fi In di.GetFiles
MsgBox("File: " & fi.FullName)
Next

Dim subDI As DirectoryInfo
For Each subDI In di.GetDirectories
DisplayFolderInfo(di.FullName & "\" & subDI.Name)
Next

End Sub

To get the process started:

DisplayFolderInfo("c:\Test")

Kerry Moorman
 
Back
Top