I am developing a software for downloading a website in C# but I have some trouble in copying the folder from server to the local directory. I am implementing following code for this purpose;
public static void CopyFilesRecursively(DirectoryInfo source, DirectoryInfo target)
{
try
{
foreach (DirectoryInfo dir in source.GetDirectories())
CopyFilesRecursively(dir, target.CreateSubdirectory(dir.Name));
foreach (FileInfo file in source.GetFiles())
file.CopyTo(Path.Combine(target.FullName, file.Name));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Form2", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
And the function call is
private void button4_Click(object sender, EventArgs e)
{
try
{
CopyFilesRecursively(new DirectoryInfo(@"https:facebook.com"), new DirectoryInfo(@"G:\Projects\"));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Form2", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
The message box shows that "the given path format is not supported."