This should work
Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sourcepath As String = "E:\temp\test\1.txt"
Dim DestPath As String = "E:\Data\"
CopyDirectory(sourcepath, DestPath)
End Sub
Private Shared Sub CopyDirectory(ByVal sourcePath As String, ByVal destPath As String)
If Not Directory.Exists(destPath) Then
Directory.CreateDirectory(destPath)
End If
For Each file__1 As String In Directory.GetFiles(Path.GetDirectoryName(sourcePath))
Dim dest As String = Path.Combine(destPath, Path.GetFileName(file__1))
File.Copy(file__1, dest)
Next
For Each folder As String In Directory.GetDirectories(Path.GetDirectoryName(sourcePath))
Dim dest As String = Path.Combine(destPath, Path.GetFileName(folder))
CopyDirectory(folder, dest)
Next
End Sub
End Class
I have changed "Directory.GetDirectories(sourcePath)"
to
"Directory.GetDirectories(Path.GetDirectoryName(sourcePath))"
Hope this helps if yes then accept and vote the answer otherwise revert back with your queries
--Rahul D.