Environment:
VS2022 on Windows 10, C#, .NET 4.8, Console App, NuGet downloaded WinSCP assembly on 2022-May-17
- On Linux:
gzip -c HUGEFILE.txt > growing.gz
- On Windows: run
Repro.cs
- While
e.FileProgress
is < 100%, callback prints out every second
- Once
e.FileProgress
hits 100%, but with the remote file is still growing, callback is called back constantly
Sample output from below program – look at the milliseconds after it hits 100%
[06:07:41.067] (0%) | [0]
[06:07:41.067] (0%) | [0]
[06:07:41.067] (0%) | [0]
[06:07:42.003] (9%) | [2,424,552]
[06:07:43.012] (26%) | [2,998,804]
[06:07:44.013] (42%) | [3,097,060]
[06:07:45.029] (51%) | [2,797,049]
[06:07:46.006] (68%) | [2,929,040]
[06:07:47.009] (85%) | [3,033,952]
[06:07:47.965] (100%) | [3,059,305]
[06:07:47.965] (100%) | [3,059,305]
[06:07:47.965] (100%) | [3,064,146]
[06:07:47.965] (100%) | [3,064,146]
private class Repro
{
public void Run()
{
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "192.168.1.42",
UserName = "username",
Password = "password",
SshHostKeyFingerprint = "ssh-ed25519 255 fingerprint",
};
using (Session session = new Session())
{
session.FileTransferProgress += Session_FileTransferProgress;
TransferOptions transferOptions = new TransferOptions
{
TransferMode = TransferMode.Binary,
ResumeSupport =
{
State = TransferResumeSupportState.On
}
};
session.Open(sessionOptions);
session.GetFiles($"/tmp/growing.gz", "growing.gz", false, transferOptions).Check();
}
}
private void Session_FileTransferProgress(object sender, FileTransferProgressEventArgs e)
{
Console.WriteLine($"[{DateTime.Now:hh:mm:ss.fff}] ({e.FileProgress:P0}) | [{e.CPS:N0}]");
}
}
static void Main(string[] args)
{
Repro r = new Repro();
r.Run();
}