Urgent: ScpClient - How to download entire remote directory to local directory

Sep 20, 2013 at 5:05 PM
Hello All,

I am trying to download all files and sub-folder from a remote directory to local directory. For this I am using "ScpClient" and method name is "Download". Based on documentation (if I have not read it wrongly) it says "Downloads the specified directory from the remote host to local directory." But the same is not happening for me.

Below is the code, please let me know if I am doing any mistake. Any pointers/help are greatly appreciated (its urgent for a go-live project).
            public void TestSynchronisation(string hostaddress, string username, string password, string hostfolderpath, string destinationPath)
        {
            using (var sftp = new ScpClient(hostaddress, username, password))
            {
                sftp.Connect();

                DirectoryInfo dirInfo = new DirectoryInfo(destinationPath);
                sftp.Downloading += sftp_Downloading;
                sftp.ErrorOccurred += sftp_ErrorOccurred;
                sftp.Download(hostfolderpath, dirInfo);            }
        }

        void sftp_ErrorOccurred(object sender, Renci.SshNet.Common.ExceptionEventArgs e)
        {
            Console.Write(e.Exception.Message.ToString());
            Console.ReadLine();
        }

        void sftp_Downloading(object sender, Renci.SshNet.Common.ScpDownloadEventArgs e)
        {
            Console.WriteLine(e.Filename.ToString());
            Console.WriteLine(e.Downloaded.ToString());
        }    
PS: It does not throw any error either shows any progress via downloading event.

Regards,
Chirag
Sep 23, 2013 at 4:24 PM
I request to the board users/senior members reply (if it is a known issue).