Using the search i've had no problems figuring out how to copy the contents of a folder from one place to another.

But what about copying sub-folders? I'd like to also copy all the sub-folders. Take a look at this:
VB Code:
  1. 'Using this import: Imports System.IO
  2.  
  3. 'Locate where the program is
  4. Dim sAppPath As String = System.Environment.CurrentDirectory
  5. 'Use the test directory with sample files in it
  6. Dim xSourceFolder As New DirectoryInfo(sAppPath & "\test")
  7. Dim xDestinationFolder As New DirectoryInfo(sAppPath & "\test2")
  8.  
  9. 'Removes previous instance of the folder and any sub-directories, then creates it fresh
  10. If xDestinationFolder.Exists = True Then xDestinationFolder.Delete(True)
  11. xDestinationFolder.Create()
  12.  
  13. 'Copies each file from the source foldr into the destination folder
  14. Dim xFile As FileInfo
  15. For Each xFile In xSourceFolder.GetFiles
  16.      xFile.CopyTo(xDestinationFolder.FullName & "\" & xFile.Name)
  17. Next xFile
  18. Beep()
What if there are a few sub-folders in the "test" folder? How can i copy them and all their contents? I know i'll need a recursive loop, but how do i identify the folder?