-
-
Notifications
You must be signed in to change notification settings - Fork 960
Closed
Description
Our SftpFileStream currently performs separate householding for read and write mode.
This means - for example - that if you:
- open an existing file for read/write
- read two bytes
- 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 (var client = new SftpClient(...))
{
client.Connect();
using (var s = client.Open(path, FileMode.CreateNew, FileAccess.Write))
{
s.Write(new byte[] { 5, 4, 3, 2, 1 }, 1, 3);
}
using (var s = 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(new byte[] {8, 9, 10, 11, 12}, 1, 3);
Console.WriteLine("#4: " + s.Position);
}
}