It's hard to compare the code, the test-case seems to be the same.
I did do a bit more analysis on my side. I don't have a reproduction case in c#, I'm only testing it using sftp-clients. What I can tell you:
- I do not have this issue using FileZilla.
- I do not have this issue using Rebex SFTP Client
- I do have this issue with WinSCP.
The call to seek is always as follows: Offet = 0, SeekOrigin.End
I get this call before the first byte is send to the stream followed by a call after every 32768 bytes (so at a total amount of bytes written to the stream of 0, 32768, 65536, 98304, ...)
If it helps, below is the stack-trace when the Seek is called.
at Empirion.FileServer.Sftp.Models.SftpWriteStream.Seek(Int64 offset, SeekOrigin origin)
at mwksu.kqmgx.iislt.dvmxq(riwhi p0, Int64 p1)
at mwksu.xtjrq.hvury.kswzo(riwhi p0, Int64 p1)
at mwksu.xepcn.ljmpl(dszdt p0, Int32 p1)
at mwksu.xepcn.mynxn(dszdt p0)
at mwksu.hnlwy.omgui(Object p0)
at mwksu.xatng.pwrda.mqfxr(Object p0)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()