/// <summary>
/// Downloads the specified directory from the remote host to local directory.
/// </summary>
/// <param name="directoryName">Remote host directory name.</param>
/// <param name="directoryInfo">Local directory information.</param>
/// <exception cref="ArgumentNullException"><paramref name="directoryInfo"/> or <paramref name="directoryName"/> is null.</exception>
public void Download(string directoryName, DirectoryInfo directoryInfo)
{
if (directoryInfo == null)
throw new ArgumentNullException("directoryInfo");
if (string.IsNullOrEmpty(directoryName))
throw new ArgumentException("directoryName");
using (var input = new PipeStream())
using (var channel = this.Session.CreateChannel<ChannelSession>())
{
channel.DataReceived += delegate(object sender, Common.ChannelDataEventArgs e)
{
input.Write(e.Data, 0, e.Data.Length);
input.Flush();
};
channel.Open();
// Send channel command request
channel.SendExecRequest(string.Format("scp -prf \"{0}\"", directoryName));
this.SendConfirmation(channel); // Send reply
this.InternalDownload(channel, input, directoryInfo);
channel.Close();
}
}