I'm using the below code(WinScp nuget) to connect to Sftp server, and it works well. I was able to list the files in present in Sftp server.
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "tst.tst.tt",
UserName = "test",
SshHostKeyFingerprint = "ssh-ed25519 255 xxxxxxxxxxxxxxxxxxxxx=",
SshPrivateKeyPath = @"D:\tst\key.ppk",
PrivateKeyPassphrase = "asdfghwetrtert",
};
sessionOptions.AddRawSettings("FSProtocol", "2");
using (Session session = new Session())
{
session.Open(sessionOptions);
RemoteDirectoryInfo directory = session.ListDirectory("/home/prod/Input");
foreach (RemoteFileInfo fileInfo in directory.Files)
{
Console.WriteLine(
"{0} with size {1}, permissions {2} and last modification at {3}",
fileInfo.Name, fileInfo.Length, fileInfo.FilePermissions,
fileInfo.LastWriteTime);
}
}
I have a zip file present in Sftp, is it possible to download only a particular file from zip instead of downloading the entire zip file ?