SSH.NET icon indicating copy to clipboard operation
SSH.NET copied to clipboard

DownloadFile hangs after downloading file

Open mrlife opened this issue 7 months ago • 3 comments

In the following example, only the "Begin download" console log is written. It successfully downloads the file, but never moves beyond the line with DownloadFile. No errors are thrown, and nothing shows up using the new logging with LogLevel.Trace.

If I add a downloadCallback to DownloadFile, that is called, yet it still never moves forward from that line.

Any ideas what could be happening?

using var sftp = new SftpClient("host", 123, "username", "password"));
sftp.Connect();

using (var fileStream = File.Create(@"C:\target\local\path\file.zip"))
{
    Console.WriteLine("Begin download");
    sftp.DownloadFile("/source/remote/path/file.zip", fileStream);
    Console.WriteLine("End download");
}

Console.WriteLine("Done");

mrlife avatar Mar 10 '25 22:03 mrlife