Posted By

krlogin11 on 07/24/10


Tagged


Versions (?)

Copy Directory


 / Published in: VB.NET
 

  1. ''' <summary>
  2. ''' Copies folder
  3. ''' </summary>
  4. ''' <param name="_srcPath">Source folder to copy</param>
  5. ''' <param name="_destPath">Target folder</param>
  6. ''' <remarks></remarks>
  7. Public Shared Sub CopyDir(ByVal _srcPath As String, ByVal _destPath As String)
  8. If Not Directory.Exists(_destPath) Then
  9. Directory.CreateDirectory(_destPath)
  10. End If
  11. Dim files() As String
  12. files = Directory.GetFileSystemEntries(_srcPath)
  13. For Each element As String In files
  14. 'Sub directories
  15. If Directory.Exists(element) Then
  16. CopyDir(element, Path.Combine(_destPath, Path.GetFileName(element)))
  17. Else 'Files
  18. File.Copy(element, Path.Combine(_destPath, Path.GetFileName(element)), True)
  19. End If
  20. Next
  21. End Sub

Report this snippet  

You need to login to post a comment.