Hi PRA,
Check this example. Now please take its reference and correct your code.
C#
protected void btnCopy_Click(object sender, EventArgs e)
{
var remote = @"\\192.168.1.1\";
var local = @"D:\";
// Create all the directories.
foreach (string dirPath in Directory.GetDirectories(remote, "*", SearchOption.AllDirectories))
{
Directory.CreateDirectory(dirPath.Replace(remote, local));
}
// Copy all the files & Replaces any files with the same name.
foreach (string newPath in Directory.GetFiles(remote, "*.*", SearchOption.AllDirectories))
{
File.Copy(newPath, newPath.Replace(remote, local), true);
}
}
VB.Net
Protected Sub btnCopy_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim remote = "\\192.168.1.1\"
Dim local = "D:\"
' Create all the directories.
For Each dirPath As String In Directory.GetDirectories(remote, "*", SearchOption.AllDirectories)
Directory.CreateDirectory(dirPath.Replace(remote, local))
Next
' Copy all the files & Replaces any files with the same name.
For Each newPath As String In Directory.GetFiles(remote, "*.*", SearchOption.AllDirectories)
File.Copy(newPath, newPath.Replace(remote, local), True)
Next
End Sub