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

SftpClient.ListDirectory().ToList() now returns list of (ISftpFile) instead of (SftpFile)

Open brhunt1958 opened this issue 2 years ago • 2 comments

Is this by design?

I just upgraded SSH.Net (via NuGet) to the most current version.

My ListDirectory used to return SftpFile, now returns ISftpFile.

I have worked around this by casting: List<SftpFile> listFileNames = (sftp.ListDirectory("/Outbound/").Cast<SftpFile>()).ToList();

This works, but is the ISftpFile return a bug? Or is this the new-normal?

Thanks.

Bryan Hunt

brhunt1958 avatar Oct 26 '23 16:10 brhunt1958

It's by design. I think it was done to allow people to mock the returned value. The instance that is returned is indeed of type SftpFile. Since SftpFile is sealed, this should not affect performance on (modern) .NET . Why do you cast it to SftpFile?

drieseng avatar Oct 26 '23 18:10 drieseng

Gert,

Only because that is what is was in the old version. If ISftpFile will work the same functionally, I can take the cast off.

Thanks.

Bryan

brhunt1958 avatar Oct 26 '23 19:10 brhunt1958