public void Download(string filename, FileInfo fileInfo)
{
if (string.IsNullOrEmpty(filename))
throw new ArgumentException("filename");
if (fileInfo == null)
throw new ArgumentNullException("fileInfo");
using (var input = ServiceFactory.CreatePipeStream())
using (var channel = Session.CreateChannelSession())
{
channel.DataReceived += (sender, e) => input.Write(e.Data, 0, e.Data.Length);
channel.Open();
// Send channel command request
channel.SendExecRequest(string.Format("scp -pf \"{0}\"", filename));
SendConfirmation(channel); // Send reply
InternalDownload(channel, input, fileInfo);
}
}