'The following code loops through all the files and folders in c:\drive.
Imports System.IO
Module Module1
Sub Main()
PrintFiles("c:\")
End Sub
Private Sub PrintFiles(ByVal root As String)
'Write the folder name
Console.WriteLine("Folder: " + root + Environment.NewLine)
'Write all the files in this folder
For Each fileName As String In Directory.GetFiles(root)
Console.WriteLine("File: " + fileName + Environment.NewLine)
Next
'If there are directories in this folder process them
For Each foundDir As String In Directory.GetDirectories(root)
Try
PrintFiles(foundDir)
Catch
'In case of some exceptions
End Try
Next
End Sub
End Module