In your code, you are calling File.OpenRead(item.path)
, which opens a local file; however, the item
instance is of type SftpItem
, which represents an item on SFTP server (not local item).
You can download a file from SFTP server into memory like this:
// download a file into memory
MemoryStream inMemoryCopy = new MemoryStream();
client.GetFile(item.Path, inMemoryCopy);
// set position to 0 for further processing (if necessary)
inMemoryCopy.Position = 0;