Skip to content

Consider revising behavior of SftpFileStream #194

Description

@drieseng

Our SftpFileStream currently performs separate householding for read and write mode.
This means - for example - that if you:

  1. open an existing file for read/write
  2. read two bytes
  3. write a single byte

The byte that you wrote in step 3 is actually written at position 0 instead of 2.

The following code fragment exposes this:

using(varclient=newSftpClient(...)){client.Connect();using(vars=client.Open(path,FileMode.CreateNew,FileAccess.Write)){s.Write(newbyte[]{5,4,3,2,1},1,3);}using(vars=client.Open(path,FileMode.Open,FileAccess.ReadWrite)){Console.WriteLine("#1: "+s.ReadByte());Console.WriteLine("#2: "+s.ReadByte());Console.WriteLine("#3: "+s.Position);s.WriteByte(7);s.Write(newbyte[]{8,9,10,11,12},1,3);Console.WriteLine("#4: "+s.Position);}}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions